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

Add resolverValidationOptions parameter to addMocksToSchema #6339

Open
sachinnash opened this issue Jul 11, 2024 · 0 comments
Open

Add resolverValidationOptions parameter to addMocksToSchema #6339

sachinnash opened this issue Jul 11, 2024 · 0 comments

Comments

@sachinnash
Copy link

sachinnash commented Jul 11, 2024

Is your feature request related to a problem? Please describe.

I am dynamically generating resolvers from a schema. These resolvers are then passed as parameters to addMocksToSchema:

  const server = new ApolloServer({
    schema: addMocksToSchema({
      schema: makeExecutableSchema({ typeDefs: typeDefs }),
      mocks: mocks,
      resolvers: generatedResolvers
    }),
  });

Internally, these are passed to addResolversToSchema (in graphql-tools/schema), which fails with the error ${typeName}.${fieldName} defined in resolvers, but not in schema. This failure can be avoided by sending resolverValidationOptions = { requireResolversToMatchSchema: 'ignore'/'warn' } to addResolversToSchema.

To achieve this, we need to add the resolverValidationOptions parameter to addMocksToSchema, which will then pass it to addResolversToSchema.

Describe the solution you'd like

Modify the addMocksToSchema definition to accept a resolverValidationOptions parameter.
This parameter will be passed to addResolversToSchema.

Describe alternatives you've considered

Manually filtering out the extra resolvers from the generatedResolvers - very much prone to failure.

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant