Custom scalars

node v10.24.1
version: 1.0.0
endpointsharetweet
const { graphql, GraphQLObjectType, GraphQLSchema, } = require('graphql'); const { mergeSchemas } = require('graphql-tools-fork'); const CustomGraphQLDateType = require('graphql-custom-datetype'); const now = new Date(); const clockSchema = new GraphQLSchema({ query: new GraphQLObjectType({ name: 'clock', fields: { now: { resolve: () => now, type: CustomGraphQLDateType, } }, }) }); graphql( clockSchema, '{ now }' ).then(result => { console.assert( result.data.now == now.toISOString(), 'clock schema out of sync with the now' ); }).catch(e => { console.log(e); }); const theGrandSchema = mergeSchemas({ schemas: [clockSchema], }); graphql( theGrandSchema, '{ now }' ).then(result => { console.log(result); console.assert( result.data.now == now.toISOString(), 'the grand schema out of sync with the now' ); }).catch(e => { console.log(e); });
Loading…

no comments

    sign in to comment