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

generate throw Cannot query field 'isOneOf' #316

Closed
3 tasks done
Hashs7 opened this issue Jun 12, 2024 · 3 comments · Fixed by #317
Closed
3 tasks done

generate throw Cannot query field 'isOneOf' #316

Hashs7 opened this issue Jun 12, 2024 · 3 comments · Fixed by #317

Comments

@Hashs7
Copy link

Hashs7 commented Jun 12, 2024

Describe the bug

When I'm running the command gql.tada generate output using version above 1.7.0, I encounter an error: Cannot query field 'isOneOf' on type '__Type'.

Behavior

The command should generate the file graphql-env.d.ts but it throw the error without creating the file.
It seems like gql.tada is trying to query a field that doesn't exist in our schema.
Our GraphQL API endpoint https://api.oees-kraken.energy/v1/graphql/ doesn't expose the isOneOf field on the __Type.
This suspected PR might have introduce this bug.

There is an possible solution to ensure that the field exists before trying to query it ?

Reproduction

npx gql.tada generate schema 'https://api.oees-kraken.energy/v1/graphql/'

gql.tada version

gql.tada >= v1.7.0

Validations

  • I can confirm that this is a bug report, and not a feature request, RFC, question, or discussion, for which GitHub Discussions should be used
  • Read the docs.
  • Follow our Code of Conduct
@JoviDeCroock
Copy link
Member

JoviDeCroock commented Jun 12, 2024

That would mean that when we run the supportQuery that the introspection of the introspection tells us we can use that property 😅 When we execute this query we derive whether you support isOneOf on __Type. When we see the property is present we'll add it to the introspection like this.

Would you mind running the support query on your endpoint and seeing what it comes up with? Mind also check the definition of __Type?

I wonder whether this is related to graphql/graphql-js#4078

@kitten
Copy link
Member

kitten commented Jun 12, 2024

We could probably make this more obvious in the CLI, but the issue here is that the support query fails with authorization errors (see link)

The problem is pretty common with GraphQL APIs that, over HTTP, require someone to authenticate before sending requests, but that's why we often recommend to use a source SDL file instead.

In this case, the API seems to guard against __type selections, but does allow __schema, which is unusual and feels unintentional

@kitten
Copy link
Member

kitten commented Jun 12, 2024

I've submitted a fix, since I think we can have better fallback behaviour here

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

Successfully merging a pull request may close this issue.

3 participants