@graphql-ez/plugin-scalars
v0.8.1
Published
Integration with [GraphQL Scalars](https://www.graphql-scalars.dev/)
Downloads
30
Readme
@graphql-ez/plugin-scalars
Integration with GraphQL Scalars
Currently this plugin requires the presence of Schema Plugin or GraphQL Modules Plugin in the same EZ App.
Usage
Check the GraphQL Scalars website docs to see all available scalars, of you can inspect the types of the plugin
import { ezScalars } from '@graphql-ez/plugin-scalars';
const ezApp = CreateApp({
ez: {
plugins: [
// ...
ezScalars({
// ...
}),
],
},
// ...
});
This plugin accepts different syntaxes:
Wildcard
If you specify "*", every scalar is added to you GraphQL Schema.
ezScalars('*');
Array
ezScalars(['DateTime', 'JSONObject']);
Object
ezScalars({
// You can use `1` | `0`
DateTime: 1,
// or `true` | `false`
JSONObject: true,
});
Custom Scalars / Override Resolvers
You can specify custom scalars
or override the existing scalars resolvers
with the second options parameter:
import { GraphQLScalarType } from 'graphql';
ezScalars(
{
DateTime: 1,
},
// Custom Scalars / Override
{
DateTime: new GraphQLScalarType({
name: 'DateTime',
// ...
}),
// New Custom Scalar
IntID: new GraphQLScalarType({
name: 'IntID',
// ...
}),
}
);