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

Error: Cannot return null for non-nullable field when using multiple source handlers #4862

Open
1 of 4 tasks
uknowpro opened this issue Nov 28, 2022 · 2 comments
Open
1 of 4 tasks

Comments

@uknowpro
Copy link

uknowpro commented Nov 28, 2022

Issue workflow progress

Progress of the issue based on the Contributor Workflow

  • 1. The issue provides a reproduction available on Stackblitz

Make sure to fork this template and run yarn generate in the terminal.

Please make sure Mesh package versions under package.json matches 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
[CASE 1] Use merger: bare And multiple source handler(graphql, openapi) in mesh config

  1. Use graphql from graphql handler
  2. Then "Error: Cannot return null for non-nullable field" occurred.
  • Using graphql from openapi handler is normal

[CASE 2] Un-use merger: bare And multiple source handler(graphql, openapi) in mesh config

  1. Use graphql from graphql handler or openapi handler
  2. Then "TypeError: Cannot read properties of undefined (reading 'Query')" occurred.
  • The above two erros are occurred. (if namingConvention.mode is set to bare or wrap.)

To Reproduce
Steps to reproduce the behavior:

  1. Go to: https://stackblitz.com/edit/node-hvpuk3
  2. yarn
  3. yarn start
  4. In the GraphiQL Ui try the following query
query getUserInfo {
  getUserInfo(id: "1") {
    id
  }
}

image

Expected behavior
When using graphql and openapi handlers, I want the query to work by applying transforming normally without errors.

  • (actual use) transforms
    • namingConvention
    • rename
    • filterSchema
    • resolversComposition

Environment:

  • OS: MacOS
  • @graphql-mesh/...:
    "@graphql-mesh/cli": "^0.80.1",
    "@graphql-mesh/config": "^8.0.34",
    "@graphql-mesh/graphql": "^0.32.2",
    "@graphql-mesh/merger-bare": "^0.15.49",
    "@graphql-mesh/openapi": "^0.33.38",
    "@graphql-mesh/runtime": "^0.44.35",
    "@graphql-mesh/transform-filter-schema": "^0.14.112",
    "@graphql-mesh/transform-naming-convention": "^0.12.2",
    "@graphql-mesh/transform-rename": "^0.13.1",
    "@graphql-mesh/transform-resolvers-composition": "^0.12.110"
  • NodeJS: 16.13.0

Additional context
If downgrade only the @graphql-mesh/runtime to version 0.43.4 in the above package, all of the mentioned errors will not occur. All other conditions are the same.

@uknowpro uknowpro changed the title Error: Cannot return null for non-nullable field (source from graphql handler) Error: Cannot return null for non-nullable field when using multiple source handler Nov 28, 2022
@uknowpro uknowpro changed the title Error: Cannot return null for non-nullable field when using multiple source handler Error: Cannot return null for non-nullable field when using multiple source handlers Nov 28, 2022
@ardatan
Copy link
Owner

ardatan commented Nov 28, 2022

Bare merger and transforms cannot be used with GraphQL sources. You should always use wrap mode with GraphQL Sources.

@uknowpro
Copy link
Author

uknowpro commented Nov 28, 2022

if do not use bare merger, this response error occurs in both graphql source and openapi source.
"TypeError: Cannot read properties of undefined (reading 'Query')"
image

transform is applied to the openapi source, there is no error. (sure graphql source)

  • (But) graphql-mesh/runtime@0.43.4
  • no use bare merge
  • wrap mode (namingConvention, rename, filterSchema, resolversComposition)

@theguild-bot theguild-bot mentioned this issue Nov 28, 2022
@theguild-bot theguild-bot mentioned this issue Sep 28, 2023
This was referenced Apr 30, 2024
This was referenced May 7, 2024
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

2 participants