0no-co / gql.tada

🪄 Magical GraphQL query engine for TypeScript
https://gql-tada.0no.co
MIT License
2.58k stars 43 forks source link

`generate` throws `CombinedError: [GraphQL] Cannot query field "isOneOf" on type "__Type"` #393

Closed david-guevara-gorillalogic closed 1 month ago

david-guevara-gorillalogic commented 1 month ago

Describe the bug

Hello!

I am having an issue when executing gql.tada generate output and gql.tada generate schema. It was working a few weeks ago, I am not sure when it stopped working.

 ⚠ Unexpected Error 
Failed to load schema.
┗ CombinedError: [GraphQL] Cannot query field "isOneOf" on type "__Type".
      at makeResult (file://$HOME/.asdf/installs/nodejs/20.12.2/lib/node_modules/gql.tada/node_modules/@gql.tada/internal/dist/gql-tada-internal.mjs:843:38)
      at fetchOperation (file://$HOME/.asdf/installs/nodejs/20.12.2/lib/node_modules/gql.tada/node_modules/@gql.tada/internal/dist/gql-tada-internal.mjs:1160:48)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async file://$HOME/.asdf/installs/nodejs/20.12.2/lib/node_modules/gql.tada/node_modules/@gql.tada/internal/dist/gql-tada-internal.mjs:445:20

This could be related to #316. I tried with the url specified in that issue and it worked properly, so it is probably something related to the schema URL that I am using (which sadly I cannot share as it is behind a VPN).

Reproduction

gql.tada generate output

gql.tada version

gql.tada v1.8.7

Validations

david-guevara-gorillalogic commented 1 month ago

When introspecting the schema I found this at the very top:

"""
Indicates exactly one field must be supplied and this field must not be `null`.
"""
directive @oneOf on INPUT_OBJECT

It is the only usage I found of @oneOf.

kitten commented 1 month ago

Can you give us more information on what version of GraphQL your API is using?

david-guevara-gorillalogic commented 1 month ago

The backend seems to be using the java package apollo-api-java (com.apollographql.apollo3) with the version 3.8.1.

kitten commented 1 month ago

In that case, I'd need a reproduction URL to actually test this properly. Our introspection basically checks for the presence of isOneOf on __Type's definition before querying isOneOf on __Type. In other words, we do a two-phase introspection, so I'd need to check if the API is misbehaving, since I couldn't spot anything wrong on our end.

If it is, then it's potentially an issue with apollo-api-java

david-guevara-gorillalogic commented 1 month ago

In the meanwhile a workaround is downloading the schema manually from the Apollo Introspection page (the SDL tab).

image

I am documenting it in case someone finds this issue and needs a workaround too.

kitten commented 1 month ago

Without a reproduction, I'll probably have to close this out, sorry. But what I can say is that there's a chance that whatever apollo-api-java outputs as an introspection for __Type, doesn't actually match up with what it accepts during a query on __Type — in other words, it might be defining a field for __Type.isOneOf but doesn't actually allow us to select it

david-guevara-gorillalogic commented 1 month ago

Without a reproduction, I'll probably have to close this out, sorry.

No problem, thank you!

wweaver commented 1 month ago

I had posted an example before, but since deleted because it was my mistake. This seems like a problem with my server. It's returning that it supports isOneOf but then when the followup query is made it complains that isOneOf is not supported. I'm going to try to see if I can update.