Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graphQLSchemaExtension custom GraphQL resolvers not replacing defaults #7527

Closed
dcousens opened this issue May 11, 2022 · 4 comments · Fixed by #7644
Closed

graphQLSchemaExtension custom GraphQL resolvers not replacing defaults #7527

dcousens opened this issue May 11, 2022 · 4 comments · Fixed by #7644
Assignees
Labels
🐛 bug Unresolved bug

Comments

@dcousens
Copy link
Member

dcousens commented May 11, 2022

export const extendGraphqlSchema = graphQLSchemaExtension<Context>({
  // ...
  resolvers: {
    Mutation: {
      // TODO: this isn't working, it isn't being called, nor is a Post actually deleted
      deletePost: (root, { id }, context) => {
        return context.db.Post.updateOne({
          where: { id },
          data: {
            isDeleted: true
          }
        });
      }
    },
  },
  // ...
})

See working example of the problem in 285b948

@borisno2
Copy link
Member

borisno2 commented May 11, 2022

So this looks to be an issue with the mergeSchema in @graphql-tools/schema just here... adding extractedResolvers.push(config.resolvers); to after the for loop pushes the custom GraphQl resolver into the array and it works.

something like this

for (const schema of schemas) {
  extractedTypeDefs.push(schema);
  extractedResolvers.push(utils.getResolversFromSchema(schema));
  extractedSchemaExtensions.push(merge.extractExtensionsFromSchema(schema));
}

extractedResolvers.push(config.resolvers);

return makeExecutableSchema({
        parseOptions: config,
        ...config,
        typeDefs: extractedTypeDefs,
        resolvers: extractedResolvers,
        schemaExtensions: extractedSchemaExtensions,

Looking deeper I have found this Github issue ardatan/graphql-tools#4367 with a PR that has been open for a month, will follow up on that PR.

@borisno2
Copy link
Member

New PR in upstream package ardatan/graphql-tools#4455

@borisno2
Copy link
Member

Updated PR in upstream package ardatan/graphql-tools#4463

@dcousens dcousens added the 🐛 bug Unresolved bug label Jun 2, 2022
@dcousens
Copy link
Member Author

dcousens commented Jun 9, 2022

If we don't have a resolution, could we drop using graphql-tools and write something that works for us?

@dcousens dcousens assigned borisno2 and unassigned borisno2 Jun 9, 2022
@dcousens dcousens changed the title Custom GraphQL resolvers not replacing defaults graphQLSchemaExtension custom GraphQL resolvers not replacing defaults Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Unresolved bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants