americanexpress / nodes

A GraphQL JVM Client - Java, Kotlin, Scala, etc.
Apache License 2.0
307 stars 70 forks source link

Arguments on aliases #67

Open hhocine opened 5 years ago

hhocine commented 5 years ago

Hi, I'm trying to send a request on a model where I have at the same level two same nodes with identical names and arguments. So I used alias graphQLPropertyName. Problem is I cannot inject the arguments on request. In the given example I want to do:

GraphQLTemplate graphQLTemplate = new GraphQLTemplate();

GraphQLRequestEntity requestEntity = GraphQLRequestEntity.Builder()
    .url("http://graphql.example.com/graphql");
    .variables(new Variable("timeFormat", "MM/dd/yyyy"))
    .arguments(new Arguments("path.to.argument.property",
        new Argument("id", "toto")))
.arguments(new Arguments("path.to.argument.propertyWithDifferentAlias",
        new Argument("id", "titi")))
    .request(SampleModel.class)
    .build();
GraphQLResponseEntity<SampleModel> responseEntity = graphQLTemplate.query(requestEntity, SampleModel.class);

However the API does not validate my query (while it has the proper syntax). Here is a simplified error message:

Unrecognized field "propertyWithDifferentAlias" (class SampleModel), not marked as ignorable ( known properties: "property])

How can I inject "id" "titi" to my aliased property?