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

TypeSafe Client how to use List of Ids #1359

Closed
robp94 opened this issue Apr 19, 2022 · 4 comments · Fixed by #1365
Closed

TypeSafe Client how to use List of Ids #1359

robp94 opened this issue Apr 19, 2022 · 4 comments · Fixed by #1365

Comments

@robp94
Copy link
Contributor

robp94 commented Apr 19, 2022

How to have a List of Ids as Parameter.
For the server, I can do something like this:

@NonNull
fun getByIds(@Id @NonNull ids: List<String>): Uni<List<Order>> {

(kotlin not tested in java, but should be similar)
which results in graphql like this:

"Query root"
type Query {
  _entities(representations: [_Any!]!): [_Entity]!
  _service: _Service!
  getByIds(ids: [ID]!): [Order]!
}

But if I create a Client with Java or Kotlin like this:

    Uni<List<Order>> getOrdersByIds(@Id @NonNull List<String> ids);

I get an error

GraphQlClientException: errors from service
errors:
- Error{message=Validation error of type VariableTypeMismatch: Variable type 'ID!' doesn't match expected type '[ID]!' @ 'getOrdersByIds', locations=[{line=1, column=55}], path=null, extensions={queryPath=["getOrdersByIds"], description=Variable type 'ID!' doesn't match expected type '[ID]!', classification=ValidationError, validationErrorType=VariableTypeMismatch}})

I can't put the Annotation inside the list like:

Uni<List<OrderGQL>> getOrdersByIds(@NonNull List<@Id String> ids);

Since the target is not allowed.

Without the Id Annotation, it does work.

@phillip-kruger
Copy link
Member

@jmartisk can you help ?

@jmartisk
Copy link
Member

Please check if #1365 helps

@robp94
Copy link
Contributor Author

robp94 commented Apr 21, 2022

From the code it looks good, I will try to test it later or tomorrow.

@robp94
Copy link
Contributor Author

robp94 commented Apr 22, 2022

I only have quarkus based tests. The current quarkus version seems not to work with the branch, so I can't test it.

If it is possible to get a schema with list of IDs in the client, it should be fine:

ids(list: [ID]): String

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 a pull request may close this issue.

3 participants