This repository has been archived by the owner on Aug 2, 2023. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello!
It leads to syntax errors if there are empty blocks '{ }' in graphql requests. There will be an empty block in your request if you create a mutation with no response defined. In this case you have one property (mutation's name) with several arguments but no children.
For example:
An empty class defining the mutation request:
@GraphQLProperty(name="myMutation", arguments={ @GraphQLArgument(name="myArgument1"), @GraphQLArgument(name="myArgument2") }) public class MyMutationModel {}
Creating the request:
GraphQLRequestEntity requestEntity = GraphQLRequestEntity.Builder() .url("http://graphql.example.com/graphql"). .arguments(new Arguments("myMutation", new Argument("myArgument1", "value1"), new Argument("myArgument2", "value2"))) .request(MyMutationModel.class) .build(); GraphQLResponseEntity<Boolean> responseEntity = graphQLTemplate.query(requestEntity, Boolean.class);
The created request would look like this:
mutation {myMutation(myArgument1:"value1", myArgument2:"value2") { } }
But a vlid request has to look like this:
mutation {myMutation(myArgument1:"value1", myArgument2:"value2") }
I think it would be a good idea to prevent empty blocks from being created in general. Because Property.class' member variable "children" is an empty map, at least in this case, it is very likely that empty blocks will be created.
My little modification would fix this behaviour. Or is there another way to deal with requests like this?
Cheers,
Christian