graphql-tools
graphql-tools copied to clipboard
Failed `batchDelegateToSchema` call doesn't throw/expose errors
Issue workflow progress
Progress of the issue based on the Contributor Workflow
- [ ] 1. The issue provides a reproduction available on Github, Stackblitz or CodeSandbox
Make sure to fork this template and run
yarn generatein the terminal.Please make sure the GraphQL Tools package versions under
package.jsonmatches yours. - [ ] 2. A failing test has been provided
- [ ] 3. A local solution has been provided
- [ ] 4. A pull request is pending review
Describe the bug
Hello!
I've encountered a number of situations where an error has been encountered while calling batchDelegateToSchema and it's exceptionally hard to find out what went wrong because the function resolves successfully and returns null.
To Reproduce
Steps to reproduce the behavior:
Run batchDelegateToSchema against a schema and specify a fieldName that isn't on the target schema.
// ...
batchDelegateToSchema({
fieldName: "invalidFieldName",
key,
schema,
validateRequest: true,
argsFromKeys: (ids) => ({ ids }),
context,
info,
});
Expected behavior
- The promise returned from
batchDelegateToSchemathrows with an error indicating the outgoing query is invalid
Actual behavior
The promise resolves and returns null. There is seemingly no means for seeing the underlying error thrown lower in the call stack (onLocatedError doesn't throw).
Environment:
- OS: macOS
- "@graphql-tools/batch-delegate": "^9.0.2",
- "@graphql-tools/delegate": "^10.0.10",
- NodeJS: 20
Additional context
There's another error I'm encountering exclusively in live environments. Again, I don't really see a way to debug it because the function returns and onLocatedError doesn't get called.
Thanks!
Could you create a reproduction on CodeSandbox or a failing test in a PR? Thanks.