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

slash graphql introspection query fails with apollo client #5792

Closed
martaver opened this issue Jul 1, 2020 · 4 comments · Fixed by #5827
Closed

slash graphql introspection query fails with apollo client #5792

martaver opened this issue Jul 1, 2020 · 4 comments · Fixed by #5827
Labels
area/graphql Issues related to GraphQL support on Dgraph. status/accepted We accept to investigate/work on it.

Comments

@martaver
Copy link

martaver commented Jul 1, 2020

I'm testing Slash GraphQL, and I'm using Apollo Client to send an introspection query to my /graphql instance.

Getting the introspection JSON is important because it allows us to codegen in the front-end.

However, when I run the introspection query with the /graphql instance, I get the following error:

GraphQL error: invalid character 'm' after object key:value pair\n" +
    "GraphQL error: Non-nullable field '__schema' (type __Schema!) was not present in result from Dgraph.  GraphQL error propagation triggered.

This same introspection query works fine with other graphql servers. I thought it likely that this is an incompatibility on dgraph's behalf.

I've set up a reproduction here: https://github.com/cleric-sh/repro/tree/dgraph-introspection

Just clone that repo, switch to the dgraph-introspection branch and do yarn && yarn update.

@gja gja added the status/accepted We accept to investigate/work on it. label Jul 2, 2020
@gja
Copy link
Contributor

gja commented Jul 2, 2020

Hi @martaver. Thanks for the bug. I think I was able to boil this down to a much simpler example. I've marked this as accepted, and we'll be looking at a fix for this.

 curl -vH "Content-Type: application/json" -d '{"operationName":"IntrospectionQuery","variables":{},"query":"query IntrospectionQuery {\n  __schema {\n    queryType {\n      name\n      __typename\n    }\n    mutationType {\n      name\n      __typename\n    }\n    subscriptionType {\n      name\n      __typename\n    }\n    types {\n      ...FullType\n      __typename\n    }\n    directives {\n      name\n      description\n      locations\n      args {\n        ...InputValue\n        __typename\n      }\n      __typename\n    }\n    __typename\n  }\n}\n\nfragment FullType on __Type {\n  kind\n  name\n  description\n  fields(includeDeprecated: true) {\n    name\n    description\n    args {\n      ...InputValue\n      __typename\n    }\n    type {\n      ...TypeRef\n      __typename\n    }\n    isDeprecated\n    deprecationReason\n    __typename\n  }\n  inputFields {\n    ...InputValue\n    __typename\n  }\n  interfaces {\n    ...TypeRef\n    __typename\n  }\n  enumValues(includeDeprecated: true) {\n    name\n    description\n    isDeprecated\n    deprecationReason\n    __typename\n  }\n  possibleTypes {\n    ...TypeRef\n    __typename\n  }\n  __typename\n}\n\nfragment InputValue on __InputValue {\n  name\n  description\n  type {\n    ...TypeRef\n    __typename\n  }\n  defaultValue\n  __typename\n}\n\nfragment TypeRef on __Type {\n  kind\n  name\n  ofType {\n    kind\n    name\n    ofType {\n      kind\n      name\n      ofType {\n        kind\n        name\n        ofType {\n          kind\n          name\n          ofType {\n            kind\n            name\n            ofType {\n              kind\n              name\n              ofType {\n                kind\n                name\n                __typename\n              }\n              __typename\n            }\n            __typename\n          }\n          __typename\n        }\n        __typename\n      }\n      __typename\n    }\n    __typename\n  }\n  __typename\n}\n"}' https://smiling-jeans-9473.us-east-1.aws.thegaas.com/graphql

@martaver
Copy link
Author

martaver commented Jul 2, 2020

Btw, if I paste the introspection query into the API Explorer on the web UI, I get the introspection JSON displayed correctly.

@martaver
Copy link
Author

martaver commented Jul 2, 2020

Okay, I was able to get the introspection working using a simpler axios request. Still scratching my head about what's special about the apollo client query... formatting maybe?

@danielmai danielmai added the area/graphql Issues related to GraphQL support on Dgraph. label Jul 2, 2020
@pawanrawal
Copy link
Contributor

I was able to reproduce this on Dgraph. It likely happens because __typename is not handled properly within the introspection code. The schema introspection query returns the correct result after __typename is removed. This should be easy to fix though, working on a fix.

pawanrawal added a commit that referenced this issue Jul 8, 2020
… introspection queries (#5827)

There was a missing " in the __typename that was filled in for types in schema introspection queries. That resulted in JSON parsing errors, we have fixed it and modified the existing test to test for it. Fixes #5792.
pawanrawal added a commit that referenced this issue Jul 8, 2020
… introspection queries (#5827)

There was a missing " in the __typename that was filled in for types in schema introspection queries. That resulted in JSON parsing errors, we have fixed it and modified the existing test to test for it. Fixes #5792.
arijitAD pushed a commit that referenced this issue Jul 14, 2020
… introspection queries (#5827)

There was a missing " in the __typename that was filled in for types in schema introspection queries. That resulted in JSON parsing errors, we have fixed it and modified the existing test to test for it. Fixes #5792.
parasssh pushed a commit that referenced this issue Jul 14, 2020
… introspection queries (#5827) (#5891)

There was a missing " in the __typename that was filled in for types in schema introspection queries. That resulted in JSON parsing errors, we have fixed it and modified the existing test to test for it. Fixes #5792.
dna2github pushed a commit to dna2fork/dgraph that referenced this issue Jul 18, 2020
… introspection queries (dgraph-io#5827)

There was a missing " in the __typename that was filled in for types in schema introspection queries. That resulted in JSON parsing errors, we have fixed it and modified the existing test to test for it. Fixes dgraph-io#5792.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/graphql Issues related to GraphQL support on Dgraph. status/accepted We accept to investigate/work on it.
4 participants