Skip to content

Interface ExecutionResult doesn't contain if data is present or not #1490

Closed

Description

@fcristovao

According to the latest GraphQL Specification (https://graphql.github.io/graphql-spec/June2018/#sec-Data):

If an error was encountered before execution begins, the data entry should not be present in the result.

If an error was encountered during the execution that prevented a valid response, the data entry in the response should be null.

Which means there's a distinction between data being returned as null, or not being returned at all.
However, the interface ExecutionResult doesn't allow to distinguish the 2 cases, since the interface only allows to get the data (either null, or T), but not to verify if there was data there to start with. ExecutionResultImpl does have this information, but since it being internal, no other code should really be using it.

Here's an example of the problem:

public ExecutionResult from(GraphQLError error){
  return new ExecutionResultImpl(error);
}

public ExecutionResult transformer(ExecutionResult result) {
  // Doesn't actually transform anything
  return new ExecutionResultImpl(result.getData(), result.getErrors(), result.getExtensions());
}

// from(someError).toSpecification() != transfomer(from(someError)).toSpecification()

So, to allow other libraries to do proper serialization based on just an ExecutionResult, isDataPresent should be part of the interface.

I've checked #552, and I think all it needs to be done is to bring the isDataPresent up to the interface, not just the implementation.

Activity

  1. fcristovao commented on Apr 9, 2019

    @fcristovao
    ContributorAuthor

    Fixed by #1491

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions