I have this type. Im using GraphQL Dgraph (not the GraphQL± or DQL)
type Respondent {
name: String
refcode: String! @id
}
Now I basically want to create a query such that I input [“refcode1”, “refcode2”] and get [{name: “johndoe”, refcode: “refcode1”}, {name: “janedoe”, refcode: “refcode2”}].
One way is to use the generated types. For example,
But, I get this error. Which seems to mean I cant pass in a list argument to a graphql query
{"errors":[{"message":"resolving updateGQLSchema failed because input:28: Type Query; Field queryRespondentsByRefcodes: Argument refcodes: must be of a scalar type. @custom DQL queries accept only scalar arguments.\n (Locations: [{Line: 3, Column: 4}])","extensions":{"code":"Error"}}]}VaseAdmins-MacBook-Pro-3:dql-test justin$
Is there a more elegant way to write this query using the generated types?
Is there a way to bypass the restriction of not having list as an argument for a custom type?
This query could be simplified if we accept a list of inputs for @id fields like we do for fields of type ID!. So if we supported that, the query would look simpler.
DQL doesn’t support list variables at present. We would need to add that capability to DQL itself, if want to pass list args to DQL. See here for DQL vars.
I feel like this is a very natural feature. In fact, I discussed with my team and we were still kinda of onboard to just use the auto-gen graphql, otherwise, we’d need to create two layers of graphql on top of each other. Bringing up that we cannot filter by non-native id in the form of a simple array just made it a clear dealbreaker.
Has an issue be made for this (shall I make one)? What kind of precedence will it take in the issue backlog?
We are going to support an IN function which allows filtering against multiple values for fields with @id directive. We’ll also look into extending this for other fields which are searchable later. Marking this as accepted.