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

@graphql-mesh/graphql fails introspection #4141

Closed
2 of 4 tasks
orcwarrior opened this issue Jul 9, 2022 · 2 comments
Closed
2 of 4 tasks

@graphql-mesh/graphql fails introspection #4141

orcwarrior opened this issue Jul 9, 2022 · 2 comments
Labels
waiting-for-answer Waiting for answer from author

Comments

@orcwarrior
Copy link

orcwarrior commented Jul 9, 2022

Issue workflow progress

Progress of the issue based on the Contributor Workflow

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

Hey guys, so it seems like for quite some time @graphql-mesh/graphql is struggling to generate GQL schema based on introspection url. I've debugged the issue for a while and my conclusions are:

  1. Seems like even if explicitly configured introspection query always uses GET method instead of POST. I believe that may be linked to issues with undici Issue on version 0.4.8 whatwg-node#52
  2. After workaround for 1st issue, second is that Hasura GraphQL Engine and also SpaceX GQL Api returns introspection in form of: {data: {__schema}} while @graphql-mesh/graphq (in: server/node_modules/@graphql-mesh/graphql/index.js:86) expects it to be just {__schema}.

To Reproduce
Steps to reproduce the behavior:

Stackblitz sandbox
Repro includes my workaround, check ./workaroundFetch.js file comments to learn more and see how it fails without hard-coding method: "POST" or dropping data.__schema -> __schema transformation of the response.

Expected behavior

Schema should get generated properly.

Environment:

  • OS: Windows 11 & "Stackblitz OS" - Unix?
  • @graphql-mesh/...: most recent
    "@graphql-mesh/cli": "0.74.1",
    "@graphql-mesh/config": "5.0.0",
    "@graphql-mesh/graphql": "0.29.1",
    "@graphql-mesh/merger-bare": "0.15.0",
    "@graphql-mesh/merger-stitching": "0.16.0",
    "@graphql-mesh/runtime": "0.41.0",
    "@graphql-mesh/store": "0.8.20",
    "@graphql-mesh/transform-resolvers-composition": "0.12.66",
    "@graphql-mesh/utils": "0.37.1",

but it also fails for older versions

    "@graphql-mesh/cli": "0.69.2",
    "@graphql-mesh/config": "0.36.1",
    "@graphql-mesh/graphql": "0.25.2",
    "@graphql-mesh/merger-bare": "0.13.43",
    "@graphql-mesh/merger-stitching": "0.15.45",
    "@graphql-mesh/runtime": "0.34.6",
    "@graphql-mesh/store": "0.8.4",
    "@graphql-mesh/utils": "0.34.6",
    "@graphql-mesh/transform-resolvers-composition": "^0.12.50",
  • NodeJS: v16

Additional context

On the sidenote, I was struggling quite a bit with having any useful debugging informations, w/o instrospection configured, I'd got errors like:

TypeError: Cannot read properties of undefined (reading 'extensions') at BareMerger.handleSingleSource (C:\Projects\trackbuild\server\node_modules\@graphql-mesh\merger-bare\index.js:28:40) at BareMerger.getUnifiedSchema (C:\Projects\trackbuild\server\node_modules\@graphql-mesh\merger-bare\index.js:48:25) at getMesh (C:\Projects\trackbuild\server\node_modules\@graphql-mesh\runtime\index.js:315:43) at async initGraphQlMesh 

which wasn't that helpful.
After adding the introspection it gives more specific error infos. But because of using it stackblitz reproduction fails, so w/o introspection & customFetch it works just fine there.
However, in my local project, it was giving me the error above. Where configuring the introspection & customFetch with a workaround resolves the issue.

Also by looking at my custom fetch impl. it seems like it's not having "typical introspection query" body delivered when using sources.graphql.introspection in config, but I had to prepare my own.
I may be a choice but it might be worth metioning in docs?

@ardatan
Copy link
Owner

ardatan commented Jul 20, 2022

  • The issue with undici has been fixed so you no longer need a custom fetch implementation
  • introspection field needs a path to the stored introspection result or schema SDL. It is not for an API endpoint.

I removed introspection and customFetch from the configuration. It seems to be working. Let me know if I am missing something.
https://stackblitz.com/edit/github-n8ptcf-ecvq55?file=.meshrc.yml

Thanks!

@ardatan ardatan added the waiting-for-answer Waiting for answer from author label Jul 20, 2022
@ardatan
Copy link
Owner

ardatan commented Jul 25, 2022

Please let us know if it still doesn't work for you. Closing this issue for now.

@ardatan ardatan closed this as completed Jul 25, 2022
@Urigo Urigo mentioned this issue Aug 11, 2022
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-for-answer Waiting for answer from author
Projects
None yet
Development

No branches or pull requests

2 participants