neo4j-graphql / neo4j-graphql-java

Neo4j Labs Project: Pure JVM translation for GraphQL queries and mutations to Neo4j's Cypher
Apache License 2.0
105 stars 49 forks source link

kotlin.KotlinNullPointerException upon calling graphql.schema() as soon as I use a UNION type #46

Open flq opened 5 years ago

flq commented 5 years ago

I suspect this can be well reproduced by providing the schema I tried:

union Thing = ThingA | ThingB

type User {
  id: ID!
  commentsOn: [Thing!] @relation(name: "COMMENTED")
}

type ThingA {
  id: ID!
}

type ThingB {
  id: ID!
}

The schema is accepted wth a call to graphql.idl but once I call graphql.schema I get

Neo.ClientError.Procedure.ProcedureCallFailed: 
Failed to invoke procedure `graphql.schema`: 
Caused by: kotlin.KotlinNullPointerException

I haven't tested whether other operations work but would open a different issue in that case, as this one is only related to graphql.schema()

flq commented 5 years ago

OK, the call from GraphiQL gives a bit more context:

kotlin.KotlinNullPointerException
    at org.neo4j.graphql.GraphQLSchemaBuilder.newReferenceField(GraphQLSchemaBuilder.kt:266)
    at org.neo4j.graphql.GraphQLSchemaBuilder.addRelationships(GraphQLSchemaBuilder.kt:232)
    at org.neo4j.graphql.GraphQLSchemaBuilder.toGraphQLObjectType(GraphQLSchemaBuilder.kt:184)
    at org.neo4j.graphql.GraphQLSchemaBuilder.graphQlTypes(GraphQLSchemaBuilder.kt:682)
    at org.neo4j.graphql.GraphQLSchemaBuilder.buildSchema(GraphQLSchemaBuilder.kt:370)
    at org.neo4j.graphql.GraphQLSchemaBuilder$Companion.buildSchema(GraphQLSchemaBuilder.kt:333)
    at org.neo4j.graphql.GraphSchema.getGraphQL(GraphSchema.kt:23)

and it is now clear that this problem inhibits performing mutations as this apparently calls into getSchema as well.

jexp commented 5 years ago

Thanks a lot also for the example.

I don't think we added support for unions yet, we plan to do it in https://github.com/neo4j-graphql/neo4j-graphql-java and then it will be available in the plugin too.

Still needs some thinking.

/cc @conker84

AnudeepKonaboina commented 4 years ago

Even without unions i am getting the same issue while creating more than one schemas. Please help me with this.

AnudeepKonaboina commented 4 years ago

when i executed this i did not get any error

call graphql.idl('type Studentdetails{ id :ID name:String age:Int }')

Then i created another schema

call graphql.idl('type Collegedetails{ id :ID name:String location:Sring students:[Studentdetails] @relation(name: "STUDYING_IN" ,direction :"IN") }')

Then when i executed

call graphql.schema()

i am getting Neo.ClientError.Procedure.ProcedureCallFailed Failed to invoke procedure graphql.schema: Caused by: kotlin.KotlinNullPointerException

Also when i refresh schema in insomnia i am getting 500 error .

Any solution to this please.