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

mergeSchemas leads to swallowed/different errors #4807

Closed
electerious opened this issue Dec 23, 2020 · 1 comment
Closed

mergeSchemas leads to swallowed/different errors #4807

electerious opened this issue Dec 23, 2020 · 1 comment

Comments

@electerious
Copy link

Using mergeSchemas together with makeExecutableSchema leads to different errors, even when just merging one schema.

Example

https://codesandbox.io/s/immutable-tdd-wlwrz?file=/index.js

// This throws "Cannot return null for non-nullable field Definition.a."
const server = new ApolloServer({
  schema: mergeSchemas({
    schemas: [createSchema()],
    resolvers: {}
  })
});

// This throws "This is an error" from the resolver
const server = new ApolloServer({
   schema: createSchema()
});

Expected behaviour

I've expected to see a "This is an error" error in the console in both cases as the typeDefs and schema is the same.

Actual behaviour

Apollo throws "Cannot return null for non-nullable field Definition.a." when using mergeSchemas and "This is an error" without mergeSchemas.

More details

  • "This is an error" is not in the console output
  • "This is an error" is not in formatError. Neither as err nor as err.originalError
  • There seems to be a relation between makeExecutableSchema, mergeTypeDefs and mergeSchemas, because it only happens when using this combination
  • Throwing the error inside the mutation resolver works and shows the error
  • I'm using apollo-server in version 2.19.0

Let me know if there's anything I can help with. It took me several hours to reproduce this bug. The code example is reduced and I'm obviously not merging one schema in the code I've actually written ;)

@glasser
Copy link
Member

glasser commented Feb 9, 2021

mergeSchemas is part of the graphql-tools project. This was previously maintained by the Apollo Server team but it is now maintained by its own community at https://www.graphql-tools.com/

While AS2 does re-export the symbols from graphql-tools v4 for "convenience", graphql-tools v4 is not being maintained. It's quite possible that your concern has already been fixed in newer versions of graphql-tools (I believe mergeSchemas is part of @graphql-tools/merge.) If the bug still exists, report it in https://github.com/ardatan/graphql-tools !

@glasser glasser closed this as completed Feb 9, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants