Skip to content

[v2] Introspection error when getting schema from GraphQL SPQR service #229

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

Closed
mkczyk opened this issue Mar 25, 2019 · 3 comments
Closed

Comments

@mkczyk
Copy link

mkczyk commented Mar 25, 2019

When I try to get schema from endpoint by Default GraphQL Endpoint -> Get GraphQL Schema from Endpoint (introspection) from service which uses GraphQL SPQR I get error:

GraphQL Introspection Error
A valid schema could not be built using the introspection result. The endpoint may not follow the GraphQL Specification. The error was:
"errors=[The field type 'Long' is not present when resolving type 'Project' [@-1:-1]]".

Stack trace:

SchemaProblem{errors=[The field type 'Long' is not present when resolving type 'Project' [@-1:-1]]}
	at graphql.schema.idl.SchemaGenerator.makeExecutableSchema(SchemaGenerator.java:270)
	at graphql.schema.idl.SchemaGenerator.makeExecutableSchema(SchemaGenerator.java:246)
	at com.intellij.lang.jsgraphql.ide.editor.GraphQLIntrospectionHelper.buildIntrospectionSchema(GraphQLIntrospectionHelper.java:300)
	at com.intellij.lang.jsgraphql.ide.editor.GraphQLIntrospectionHelper.printIntrospectionJsonAsGraphQL(GraphQLIntrospectionHelper.java:264)
	at com.intellij.lang.jsgraphql.ide.editor.GraphQLIntrospectionHelper$2.lambda$run$0(GraphQLIntrospectionHelper.java:148)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:315)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.doRun(LaterInvocator.java:435)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:419)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:403)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
	at java.awt.EventQueue.access$500(EventQueue.java:98)
	at java.awt.EventQueue$3.run(EventQueue.java:715)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:719)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:668)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:363)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

In services which doesn't use GraphQL SPQR getting schema by plugin works.

Based on this, you can think it's the GraphQL SPQR's fault. But schema can be got by other tools, for example by get-graphql-schema or graphql-cli (based on this answer).

Example with GraphQL SPQR (error only in plugin case)

(uses GraphQL Java Spring)

  1. Download https://github.com/leangen/graphql-spqr-samples
  2. Create .graphqlconfig for plugin (http://localhost:8000/graphql - pay attention to port!)
  3. Run Spring Boot StarterDemoApplication (from project spring-boot-starter-sample).
  4. Try Get GraphQL Schema from Endpoint (introspection) in plugin and get error.
  5. Try get-graphql-schema http://localhost:8000/graphql and get schema.

Example without GraphQL SPQR (without error in both case)

(uses GraphQL Spring Boot Starter)

  1. Download https://github.com/graphql-java/tutorials
  2. Create .graphqlconfig for plugin (http://localhost:8080/graphql)
  3. Run Spring Boot BookDetailsApplication (from project book-details).
  4. Try Get GraphQL Schema from Endpoint (introspection) in plugin and get schema.
  5. Try get-graphql-schema http://localhost:8080/graphql and get schema.

Example with GraphQL SPQR, but without Spring Boot (error only in plugin case)

(to eliminate fault in GraphQL Spring Boot Starter; it is pure GraphQL SPQR and GraphQL Java - so I think Spring Boot starter doesn't matter)

  1. Download https://github.com/mkczyk/hackernews-graphql-java (based on last step of this tutorial)
  2. .graphqlconfig for plugin is created (http://localhost:8000/graphql)
  3. Run mvn jetty:run (from project hackernews-graphql-java).
  4. Try Get GraphQL Schema from Endpoint (introspection) in plugin and get error.
  5. Try get-graphql-schema http://localhost:8000/graphql and get schema.

But in the last one example I get different error than first example:

GraphQL Introspection Error

A valid schema could not be built using the introspection result. The endpoint may not follow the GraphQL Specification. The error was:
"errors=[The field input type 'BigDecimal' is not present when resolving type 'QUERY_ROOT' [@-1:-1], The field input type 'BigDecimal' is not present when resolving type 'QUERY_ROOT' [@-1:-1]]".

Stack trace:

SchemaProblem{errors=[The field input type 'BigDecimal' is not present when resolving type 'QUERY_ROOT' [@-1:-1], The field input type 'BigDecimal' is not present when resolving type 'QUERY_ROOT' [@-1:-1]]}
	at graphql.schema.idl.SchemaGenerator.makeExecutableSchema(SchemaGenerator.java:270)
	at graphql.schema.idl.SchemaGenerator.makeExecutableSchema(SchemaGenerator.java:246)
	at com.intellij.lang.jsgraphql.ide.editor.GraphQLIntrospectionHelper.buildIntrospectionSchema(GraphQLIntrospectionHelper.java:300)
	at com.intellij.lang.jsgraphql.ide.editor.GraphQLIntrospectionHelper.printIntrospectionJsonAsGraphQL(GraphQLIntrospectionHelper.java:264)
	at com.intellij.lang.jsgraphql.ide.editor.GraphQLIntrospectionHelper$2.lambda$run$0(GraphQLIntrospectionHelper.java:148)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:315)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.doRun(LaterInvocator.java:435)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:419)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:403)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
	at java.awt.EventQueue.access$500(EventQueue.java:98)
	at java.awt.EventQueue$3.run(EventQueue.java:715)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:719)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:668)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:363)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

It's look like problem with getting custom scalars defined in GraphQL SPQR.

v.2.0.0-beta-1
IntelliJ IDEA 2018.3.5 Ultimate Edition

jimkyndemeyer added a commit that referenced this issue Mar 28, 2019
…'t filter out scalars that come "built-in" in graphql-java (#164, #229)
@jimkyndemeyer
Copy link
Collaborator

Thanks for testing the plugin.

I've fixed this for the upcoming beta-2 release. The introspection schema type registry based on graphql-java was filtering out scalars such as Long, BigDecimal etc. since graphql-java has these built-in.

@arielnmz
Copy link

arielnmz commented Apr 12, 2019

I have a very similar issue, this is my config:

{
  "name": "Statham API GraphQL Schema",
  "schemaPath": "schema.graphql",
  "extensions": {
    "endpoints": {
      "Default GraphQL Endpoint": {
        "url": "http://localhost:8000/gql/",
        "headers": {
          "user-agent": "JS GraphQL"
        },
        "introspect": true
      }
    }
  }
}

And the plugin fails with this error:

graphql.AssertException: Internal error: should never happen: cannot build value of ServiceStatus from StringValue{value='pending'}

Full stack
graphql.AssertException: Internal error: should never happen: cannot build value of ServiceStatus from StringValue{value='pending'}
	at graphql.Assert.assertShouldNeverHappen(Assert.java:26)
	at graphql.schema.idl.SchemaGeneratorHelper.buildValue(SchemaGeneratorHelper.java:94)
	at graphql.schema.idl.SchemaGenerator.buildInputField(SchemaGenerator.java:800)
	at graphql.schema.idl.SchemaGenerator.lambda$buildInputObjectType$24(SchemaGenerator.java:772)
	at java.base/java.util.ArrayList.forEach(Unknown Source)
	at graphql.schema.idl.SchemaGenerator.buildInputObjectType(SchemaGenerator.java:771)
	at graphql.schema.idl.SchemaGenerator.buildInputType(SchemaGenerator.java:448)
	at graphql.schema.idl.SchemaGenerator.buildInputField(SchemaGenerator.java:796)
	at graphql.schema.idl.SchemaGenerator.lambda$buildInputObjectType$24(SchemaGenerator.java:772)
	at java.base/java.util.ArrayList.forEach(Unknown Source)
	at graphql.schema.idl.SchemaGenerator.buildInputObjectType(SchemaGenerator.java:771)
	at graphql.schema.idl.SchemaGenerator.buildInputType(SchemaGenerator.java:448)
	at graphql.schema.idl.SchemaGenerator.buildArgument(SchemaGenerator.java:820)
	at graphql.schema.idl.SchemaGenerator.lambda$buildField$23(SchemaGenerator.java:702)
	at java.base/java.util.ArrayList.forEach(Unknown Source)
	at graphql.schema.idl.SchemaGenerator.buildField(SchemaGenerator.java:701)
	at graphql.schema.idl.SchemaGenerator.lambda$buildObjectType$6(SchemaGenerator.java:478)
	at java.base/java.util.ArrayList.forEach(Unknown Source)
	at graphql.schema.idl.SchemaGenerator.buildObjectType(SchemaGenerator.java:477)
	at graphql.schema.idl.SchemaGenerator.buildOutputType(SchemaGenerator.java:411)
	at graphql.schema.idl.SchemaGenerator.buildOperation(SchemaGenerator.java:343)
	at graphql.schema.idl.SchemaGenerator.makeExecutableSchemaImpl(SchemaGenerator.java:323)
	at graphql.schema.idl.SchemaGenerator.makeExecutableSchema(SchemaGenerator.java:274)
	at graphql.schema.idl.SchemaGenerator.makeExecutableSchema(SchemaGenerator.java:246)
	at com.intellij.lang.jsgraphql.ide.editor.GraphQLIntrospectionHelper.buildIntrospectionSchema(GraphQLIntrospectionHelper.java:312)
	at com.intellij.lang.jsgraphql.ide.editor.GraphQLIntrospectionHelper.printIntrospectionJsonAsGraphQL(GraphQLIntrospectionHelper.java:276)
	at com.intellij.lang.jsgraphql.ide.editor.GraphQLIntrospectionHelper$2.lambda$run$0(GraphQLIntrospectionHelper.java:160)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:315)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.doRun(LaterInvocator.java:435)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:419)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:403)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:742)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:691)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:386)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)

This is what ServiceStatus looks like (I'm using graphene-python):

class ServiceStatus(graphene.Enum):
    CANCELLED = 'cancelled'
    PENDING = 'pending'
    FINISHED = 'finished'
    ASSIGNED = 'assigned'

The GraphiQL AppImg works just fine.

Workaround:

Disable this option
image

(maybe an issue with graphene-python?)

@jimkyndemeyer
Copy link
Collaborator

jimkyndemeyer commented Apr 12, 2019

Hi @arielnmz

This is indeed an issue with spec compliance in graphene-python. Thanks for linking the issues.

For you specific schema graphene quotes an enum default value, turning it into a GraphQL string, which is not a valid way of representing a default enum value.

See #216 (comment) for more context on how the GitHub API apparently had the same issue with spec compliance on enum default values.

Best regards,
Jim.

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

3 participants