Skip to content

Add extensions-Field to GraphQLError.kt#166

Closed
MaaxGr wants to merge 13 commits into
aPureBase:mainfrom
MaaxGr:fix-165
Closed

Add extensions-Field to GraphQLError.kt#166
MaaxGr wants to merge 13 commits into
aPureBase:mainfrom
MaaxGr:fix-165

Conversation

@MaaxGr

@MaaxGr MaaxGr commented Oct 14, 2021

Copy link
Copy Markdown

Fixes #165

@MaaxGr MaaxGr changed the title Add extensions-Field to GraphQLError.kt WIP: Add extensions-Field to GraphQLError.kt Oct 14, 2021
@MaaxGr MaaxGr changed the title WIP: Add extensions-Field to GraphQLError.kt Add extensions-Field to GraphQLError.kt Oct 20, 2021
@MaaxGr

MaaxGr commented Oct 20, 2021

Copy link
Copy Markdown
Author

Tested it. Everything works:

throw GraphQLError(message = "test", extensions = mapOf("code" to "BAD_USER_INPUT"))

Returns:

{
  "errors": [
    {
      "message": "test",
      "locations": [],
      "path": [],
      "extensions": {
        "code": "BAD_USER_INPUT"
      }
    }
  ]
}

@jeggy

jeggy commented May 31, 2022

Copy link
Copy Markdown
Member

Hi @MaaxGr

This looks great!
Could you write a unit test that validates that your implementation also works?

Sorry for this late response.

@MaaxGr

MaaxGr commented May 31, 2022

Copy link
Copy Markdown
Author

Haha. Yeah of course. Hopefully that also doesn't have to wait for some months :D Let's see, when I have time for that

@jeggy

jeggy commented May 31, 2022

Copy link
Copy Markdown
Member

Sure :)
And I'm gonna make sure that this repository won't stand stale again.

We have opened GitHub discussions and I'm looking for people to help out #187 Looking for maintainers

@MaaxGr

MaaxGr commented Jul 17, 2022

Copy link
Copy Markdown
Author

Hey. I have added a unit test to verify the serialize()-Method with extensions-Object included.

But to be honest i now realize that the implementation doesn't exactly matches the spec.

GraphQL services may provide an additional entry to errors with key extensions. This entry, if set, must have a map as its value. This entry is reserved for implementors to add additional information to errors however they see fit, and there are no additional restrictions on its contents.
https://spec.graphql.org/June2018/#example-90475

This example shows that there can also be substructures in one extension, which is currently not supported in my implementation.
https://www.apollographql.com/docs/apollo-server/data/errors/

How sould we deal with this?

@MaaxGr

MaaxGr commented Aug 7, 2022

Copy link
Copy Markdown
Author

Closing this, as we probably should go with MR #171.

@MaaxGr MaaxGr closed this Aug 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Support for GraphQLError-Extension data

2 participants