Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { mergeSchemas } from 'graphql-tools';
- const createNewSchema = async () => {
- // get remote executable schema
- const schema = await createRemoteExecutableSchema();
- // write a resolver to customise the existing resolver
- const customResolvers = {
- Query: {
- game: (root, args, context, info) => {
- const validation = validateTime();
- // If validation fails, return empty, else delegate to parent schema
- if (!validation) {
- return [];
- } else {
- return info.mergeInfo.delegateToSchema({
- schema,
- operation: 'query',
- fieldName: 'game',
- args,
- context,
- info
- });
- }
- }
- }
- };
- // merge the schema along with custom resolvers
- return mergeSchemas({
- schemas: [ schema ],
- resolvers: customResolvers
- });
- };
Add Comment
Please, Sign In to add comment