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

Exception de-serializing errors sent by AWS AppSync #1062

Open
vladdex opened this issue Mar 23, 2023 · 2 comments
Open

Exception de-serializing errors sent by AWS AppSync #1062

vladdex opened this issue Mar 23, 2023 · 2 comments
Labels
breaking-change Breaking change bug Something isn't working
Milestone

Comments

@vladdex
Copy link

vladdex commented Mar 23, 2023

Issue Description

Some errors sent by an application built on AWS AppSync contain and extra field called "data" which does exist in the GraphQLError class.
Furthermore if I ignore unknown properties the GraphQLErrorType is missing error types provided by AppSync ex Lambda:Unhandled.
Is there any way to override these when generating the models ?

Steps to Reproduce

To reproduce try to de-serialize the following json into a GraphQLResult

{
    "data": null,
    "errors": [
        {
            "path": [
                "addProject"
            ],
            "data": null,
            "errorType": "Lambda:Unhandled",
            "errorInfo": null,
            "locations": [
                {
                    "line": 1,
                    "column": 23,
                    "sourceName": null
                }
            ],
            "message": "There is already a Project with name AutoProj-Duplicate1679598192925 in the system"
        }
    ]
}

Expected Result

Json should de-serialize correctly

Actual Result

De-serialization fails because "data" is an urecognised field and Lambda:Unhandled is an unrecognised error type

Your Environment and Setup

  • graphql-java-codegen version: 5.6.0
  • Build tool: Gradle
@vladdex vladdex added the bug Something isn't working label Mar 23, 2023
@kobylynskyi kobylynskyi added this to the 5.7.2 milestone Mar 24, 2023
@kobylynskyi
Copy link
Owner

kobylynskyi commented Mar 24, 2023

@vladdex so there are 2 issues:
1 - Unknown field in the response is handled solely on your side by ignoring unknown properties. There's nothing to do with this library/plugin.
2 - Unknown ErrorType - I agree that this needs to be fixed in this graphql-java-codegen plugin itself because different servers that are adopting graphql spec might have different error types. So I think the solution this case would be to change errorType field in GraphQLError class from GraphQLErrorType errorType to String errorType. This would become a breaking change and I would need to include this fix into a next major version 6.0.0. Until this is done, I suggest you to use READ_UNKNOWN_ENUM_VALUES_AS_NULL in your Jackson configuration.

@kobylynskyi kobylynskyi modified the milestones: 5.7.2, 6.0.0 Mar 24, 2023
@kobylynskyi kobylynskyi added the breaking-change Breaking change label Mar 24, 2023
@vladdex
Copy link
Author

vladdex commented Mar 24, 2023

@kobylynskyi

  1. I agree, ignoring unknown fields did the trick.
  2. Reading unknown enums as null did the trick as well.

For issue 1 I'm thinking if it would be possible to add a functionality that lets you add specific fields to certain predefined classes during code generation, remap that class to a custom one. While ignoring that field in this case is ok, because it's null, there might be cases where valuable data might be there.

Thanks,
Vlad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Breaking change bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants