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

DataFetchingException when fetching users with nodeReference fields with GraphQL #393

Closed
bernhardriegler opened this issue Apr 24, 2018 · 1 comment · Fixed by #938
Closed

Comments

@bernhardriegler
Copy link
Contributor

Gentics Mesh Version, operating system, or hardware.

  • v0.18.2

Problem

When fetching userdata via the graphql endpoint and including the nodeReference and its fields an DataFetchingException will be thrown.
Also no fields of the referenced node will be returned

Reproducer

  • create a node to use as a reference
  • create a user and set the nodeReference property to the earlier created node
  • get users and nodeReference with fields from graphQL endpiont
    POST: {{ API }}/{{ PROJECT }}/graphql
{
  users {
    elements {
      username
      nodeReference {
        uuid
        fields {
          ... on additionalUserData {
            company
          }
        }
      }
    }
  }
}

Actual behaviour

no fields are in the response.
i.e.

{
    "errors": [{
        "message": "Exception while fetching data (/users/elements[0]/nodeReference/fields) : null",
        "type": "DataFetchingException"
    }],
    "data": {
        "users": {
            "elements": [{
                "username": "{{ USERNAME }}",
                "nodeReference": {
                    "uuid": "{{ UUID }}",
                    "fields": null
                }
            }]
        }
    }
}

Expected behaviour

all fields should be returned as queried.

{
    "data": {
        "users": {
            "elements": [{
                "username": "{{ USERNAME }}",
                "nodeReference": {
                    "uuid": "{{ UUID }}",
                    "fields": [{
                        "company": "test"
                    }]
                }
            }]
        }
    }
}
@Jotschi Jotschi changed the title DataFetchingException when fetching users with nodeReference fields with GraphQl DataFetchingException when fetching users with nodeReference fields with GraphQL Apr 25, 2018
@bernhardriegler
Copy link
Contributor Author

bernhardriegler commented Oct 18, 2019

The originally raised issue is solved by now.
However there are new issues in Gentics Mesh 1.0.2

These issues are reproducable at demo.getmesh.io

To do so please add a nodeReference to a users first.

A) using graphql v1

when requesting fields the result will contain errors for each users which does not have a nodeReference set.

mesh_1  | 13:57:13.345 [] ERROR [vert.x-worker-thread-3] [c.g.m.g.GraphQLHandler] - Error while fetching data.
mesh_1  | java.lang.ClassCastException: class com.gentics.mesh.core.data.node.impl.NodeImpl cannot be cast to class com.gentics.mesh.core.data.node.NodeContent (com.gentics.mesh.core.data.node.impl.NodeImpl and com.gentics.mesh.core.data.node.NodeContent are in unnamed module of loader 'app')
mesh_1  |       at com.gentics.mesh.graphql.type.NodeTypeProvider.lambda$null$24(NodeTypeProvider.java:503)
mesh_1  |       at graphql.execution.ExecutionStrategy.fetchField(ExecutionStrategy.java:258)
mesh_1  |       at graphql.execution.ExecutionStrategy.resolveFieldWithInfo(ExecutionStrategy.java:199)
mesh_1  |       at graphql.execution.AsyncExecutionStrategy.execute(AsyncExecutionStrategy.java:70)
mesh_1  |       at graphql.execution.ExecutionStrategy.completeValueForObject(ExecutionStrategy.java:633)
mesh_1  |       at graphql.execution.ExecutionStrategy.completeValue(ExecutionStrategy.java:413)
mesh_1  |       at graphql.execution.ExecutionStrategy.completeField(ExecutionStrategy.java:363)
mesh_1  |       at graphql.execution.ExecutionStrategy.lambda$resolveFieldWithInfo$0(ExecutionStrategy.java:201)
mesh_1  |       at java.base/java.util.concurrent.CompletableFuture.uniApplyNow(Unknown Source)
mesh_1  |       at java.base/java.util.concurrent.CompletableFuture.uniApplyStage(Unknown Source)
mesh_1  |       at java.base/java.util.concurrent.CompletableFuture.thenApply(Unknown Source)
mesh_1  |       at graphql.execution.ExecutionStrategy.resolveFieldWithInfo(ExecutionStrategy.java:200)
mesh_1  |       at graphql.execution.AsyncExecutionStrategy.execute(AsyncExecutionStrategy.java:70)
mesh_1  |       at graphql.execution.ExecutionStrategy.completeValueForObject(ExecutionStrategy.java:633)
mesh_1  |       at graphql.execution.ExecutionStrategy.completeValue(ExecutionStrategy.java:413)
mesh_1  |       at graphql.execution.ExecutionStrategy.completeValueForList(ExecutionStrategy.java:512)
mesh_1  |       at graphql.execution.ExecutionStrategy.completeValueForList(ExecutionStrategy.java:460)
mesh_1  |       at graphql.execution.ExecutionStrategy.completeValue(ExecutionStrategy.java:398)
mesh_1  |       at graphql.execution.ExecutionStrategy.completeField(ExecutionStrategy.java:363)
mesh_1  |       at graphql.execution.ExecutionStrategy.lambda$resolveFieldWithInfo$0(ExecutionStrategy.java:201)
mesh_1  |       at java.base/java.util.concurrent.CompletableFuture.uniApplyNow(Unknown Source)
mesh_1  |       at java.base/java.util.concurrent.CompletableFuture.uniApplyStage(Unknown Source)
mesh_1  |       at java.base/java.util.concurrent.CompletableFuture.thenApply(Unknown Source)
mesh_1  |       at graphql.execution.ExecutionStrategy.resolveFieldWithInfo(ExecutionStrategy.java:200)
mesh_1  |       at graphql.execution.AsyncExecutionStrategy.execute(AsyncExecutionStrategy.java:70)
mesh_1  |       at graphql.execution.ExecutionStrategy.completeValueForObject(ExecutionStrategy.java:633)
mesh_1  |       at graphql.execution.ExecutionStrategy.completeValue(ExecutionStrategy.java:413)
mesh_1  |       at graphql.execution.ExecutionStrategy.completeField(ExecutionStrategy.java:363)
mesh_1  |       at graphql.execution.ExecutionStrategy.lambda$resolveFieldWithInfo$0(ExecutionStrategy.java:201)
mesh_1  |       at java.base/java.util.concurrent.CompletableFuture.uniApplyNow(Unknown Source)
mesh_1  |       at java.base/java.util.concurrent.CompletableFuture.uniApplyStage(Unknown Source)
mesh_1  |       at java.base/java.util.concurrent.CompletableFuture.thenApply(Unknown Source)
mesh_1  |       at graphql.execution.ExecutionStrategy.resolveFieldWithInfo(ExecutionStrategy.java:200)
mesh_1  |       at graphql.execution.AsyncExecutionStrategy.execute(AsyncExecutionStrategy.java:70)
mesh_1  |       at graphql.execution.Execution.executeOperation(Execution.java:158)
mesh_1  |       at graphql.execution.Execution.execute(Execution.java:100)
mesh_1  |       at graphql.GraphQL.execute(GraphQL.java:554)
mesh_1  |       at graphql.GraphQL.parseValidateAndExecute(GraphQL.java:496)
mesh_1  |       at graphql.GraphQL.executeAsync(GraphQL.java:470)
mesh_1  |       at graphql.GraphQL.execute(GraphQL.java:401)
mesh_1  |       at com.gentics.mesh.graphql.GraphQLHandler.handleQuery(GraphQLHandler.java:60)
mesh_1  |       at com.gentics.mesh.graphql.GraphQLEndpoint.lambda$registerEndPoints$0(GraphQLEndpoint.java:48)
mesh_1  |       at io.vertx.ext.web.impl.BlockingHandlerDecorator.lambda$handle$0(BlockingHandlerDecorator.java:48)
mesh_1  |       at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$2(ContextImpl.java:316)
mesh_1  |       at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
mesh_1  |       at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
mesh_1  |       at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
mesh_1  |       at java.base/java.lang.Thread.run(Unknown Source)
mesh_1  | 13:57:13.346 [] WARN  [vert.x-worker-thread-3] [c.g.m.g.GraphQLHandler] - Encountered {13} errors while executing query {{
mesh_1  |   users {
mesh_1  |     elements {
mesh_1  |       uuid
mesh_1  |       username
mesh_1  |       firstname
mesh_1  |       lastname
mesh_1  |       emailAddress
mesh_1  |       created
mesh_1  |       groups {
mesh_1  |         elements {
mesh_1  |           name
mesh_1  |           uuid
mesh_1  |         }
mesh_1  |       }
mesh_1  |       nodeReference {
mesh_1  |         uuid
mesh_1  |         fields {
mesh_1  |             ... on additionalUserData {
mesh_1  | company
mesh_1  |             }
mesh_1  |         }
mesh_1  |       }
mesh_1  |     }
mesh_1  |   }
mesh_1  | }
mesh_1  | }
mesh_1  | 13:57:13.347 [] INFO  [vert.x-worker-thread-3] [i.v.e.w.h.i.LoggerHandlerImpl] - 172.18.0.1 - POST /api/v1/MAM_API_Assets/graphql?version=published HTTP/1.1 200 15320 - 40 ms

Here is an example running at the demo:
https://demo.getmesh.io/api/v1/demo/graphql/browser/#query=%7B%0A%20%20users%20%7B%0A%20%20%20%20elements%20%7B%0A%20%20%20%20%20%20uuid%0A%20%20%20%20%20%20nodeReference%20%7B%0A%20%20%20%20%20%20%20%20uuid%0A%20%20%20%20%20%20%20%20fields%20%7B%0A%20%20%20%20%20%20%20%20%20%20...%20on%20vehicle%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20slug%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A&variables=%7B%7D

b) when using graphql v2

internel server error is returned.
here is an example at the demo:
https://demo.getmesh.io/api/v2/demo/graphql/browser/#query=%7B%0A%20%20users%20%7B%0A%20%20%20%20elements%20%7B%0A%20%20%20%20%20%20uuid%0A%20%20%20%20%20%20nodeReference%20%7B%0A%20%20%20%20%20%20%20%20uuid%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A&variables=%7B%7D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants