yahoo / elide

Elide is a Java library that lets you stand up a GraphQL/JSON-API web service with minimal effort.
https://elide.io
Other
1k stars 229 forks source link

Cryptic error message on data passed to child entity #1470

Open codingwhatever opened 4 years ago

codingwhatever commented 4 years ago

Model

public class Incident {
    @ManyToOne
    @JoinColumn(name = "last_edited_by")
    @CreatePermission(expression = Constants.USER_VALID)
    @UpdatePermission(expression = Constants.USER_VALID)
    private User last_edited_by;
    ...
}

public class User {
    private String id;
    ...
}

Expected Behavior

Request:

{
"query": "mutation {incidents(op: UPSERT, data: {}) { last_edited_by(op: UPSERT data: {id:\"invalidUserId\"}) { edges { node { id } } }   } } } }"
}

Reasonable response:

{
  "data": null,
  "errors": [
    {
      "message": "Exception while fetching data (/incidents/edges[0]/node/last_edited_by) : null",
      "locations": [
        {
          "line": 1,
          "column": 358
        }
      ],
      "path": [
        "incidents",
        "edges",
        0,
        "node",
        "last_edited_by"
      ]
    }
  ]
}

Current Behavior

When passing data values to child entity from the parent entity's data, the response is cryptic. Broken request:

{
"query": "mutation {incidents(op: UPSERT, data: {created_by: {id:\"invalidUserId\"}}) { last_edited_by { edges { node { id } } }   } } } }"
}

Broken response:

{
  "data": null,
  "errors": [
    {
      "message": "Exception while fetching data (/incidents) : null",
      "locations": [
        {
          "line": 1,
          "column": 79
        }
      ],
      "path": [
        "incidents"
      ]
    }
  ]
}

Stacktrace:

2020-07-29 22:01:33.238 +0000 [qtp288615534-335] [App, ] DEBUG com.yahoo.elide.graphql.QueryRunner.executeGraphQLRequest - WebApplicationException
javax.ws.rs.WebApplicationException: HTTP 200 OK
        at com.yahoo.elide.graphql.QueryRunner.executeGraphQLRequest(QueryRunner.java:191)
        at com.yahoo.elide.graphql.QueryRunner.lambda$run$0(QueryRunner.java:104)
        at com.yahoo.elide.graphql.QueryRunner.run(QueryRunner.java:139)
        at com.yahoo.elide.spring.controllers.GraphqlController.post(GraphqlController.java:58)

Possible Solution

Steps to Reproduce (for bugs)

  1. Create table with Data Model listed above.
  2. Send a mutation request as specified above.

Context

Difficult to debug invalid insert values.

Your Environment

aklish commented 3 years ago

@codingwhatever GraphQL error handling was improved greatly in Elide 5. Can you rerun with Elide 5?

aklish commented 2 years ago

@codingwhatever what was the actual error in this case? Did it fail for permissions or are you providing an invalid user ID? I"m not sure how to reproduce the failure in this case.

aklish commented 2 years ago

Also - is there an ID field in the Incident model?