Skip to content

Error message payload should be an array as defined in graphql-ws protocol #203

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

Conversation

jord1e
Copy link
Contributor

@jord1e jord1e commented Nov 27, 2021

Fixes #200

This is my first ever Spring contribution, please let me know if anything should be changed.

Is there a replacement for Collections#singletonList in Spring?

Documentation describing expected behaviour:

Screenshots

In this example I modified

return Flux.just("Hi", "Bonjour", "Hola", "Ciao", "Zdravo").map(s -> s + " " + name);
to the following:

return Flux.just("Hi", "Bonjour", "Hola", "Ciao", "Zdravo").map(s -> {
    if (s.equalsIgnoreCase("Zdravo")) {
        throw new RuntimeException("Test Exception");
    }
    return s + " " + name;
});

Before:
afbeelding

After:
afbeelding

Normal (without errors):
afbeelding

@pivotal-cla
Copy link

@jord1e Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 27, 2021
@pivotal-cla
Copy link

@jord1e Thank you for signing the Contributor License Agreement!

@jvalkeal
Copy link
Contributor

I tried this on top of my #204 and errors are now coming through fine.

Previously if you did:

subscription {
  xxxx
}

GraphiQL showed:

{
  "errors": {
    "message": "Invalid message",
    "stack": "Error: Invalid message\n    at f (http://localhost:8080/graphiql/main.js:13:3297)\n    at WebSocket.o.onmessage (http://localhost:8080/graphiql/main.js:13:7311)"
  }
}

Now it correctly shows error from ws payload:

{
  "errors": {
    "message": "Execution failed: [ValidationError{validationErrorType=FieldUndefined, queryPath=[xxxx], message=Validation error of type FieldUndefined: Field 'xxxx' in type 'Subscription' is undefined @ 'xxxx', locations=[SourceLocation{line=33, column=3}], description='Field 'xxxx' in type 'Subscription' is undefined'}]",
    "stack": "Error: Execution failed: [ValidationError{validationErrorType=FieldUndefined, queryPath=[xxxx], message=Validation error of type FieldUndefined: Field 'xxxx' in type 'Subscription' is undefined @ 'xxxx', locations=[SourceLocation{line=33, column=3}], description='Field 'xxxx' in type 'Subscription' is undefined'}]\n    at Object.error (http://localhost:8080/graphiql/main.js:37:202952)\n    at Object.f67f4083-ca61-4bd2-a976-600e678d9985 (http://localhost:8080/graphiql/main.js:13:9048)\n    at emit (http://localhost:8080/graphiql/main.js:13:5564)\n    at Object.emit (http://localhost:8080/graphiql/main.js:13:6112)\n    at WebSocket.o.onmessage (http://localhost:8080/graphiql/main.js:13:7323)"
  }
}

@rstoyanchev rstoyanchev added in: web Issues related to web handling type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 29, 2021
@rstoyanchev rstoyanchev self-assigned this Nov 29, 2021
@rstoyanchev rstoyanchev added this to the 1.0.0-M4 milestone Nov 29, 2021
@rstoyanchev rstoyanchev changed the title Convert websocket error message payload to array (graphql-ws compat.) Change error message payload to be an array as defined in graphql-ws Nov 29, 2021
@rstoyanchev rstoyanchev modified the milestones: 1.0.0-M4, 1.0.0-M5 Dec 14, 2021
@rstoyanchev rstoyanchev changed the title Change error message payload to be an array as defined in graphql-ws Error message payload should be an array as defined in graphql-ws protocol Jan 17, 2022
@jord1e jord1e deleted the fix-200-errormessage-array branch January 17, 2022 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues related to web handling type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[graphql-ws] ErrorMessage.payload must always be an array
5 participants