Skip to content

Dynamic where clauses #282

Answered by dotansimha
mhpaler asked this question in Q&A
Oct 7, 2022 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

Hi @mpaler !
You can leverage the concept of GraphQL variables to achieve that.
First, you need to find the actual GraphQL input type that's defined for the where argument you with to match, and then use that input type for your GraphQL query, as a variable (similar to the example you shared). You can do that with GraphiQL, or just introspect the schema and check the API docs of your field.

For example, for this Subgraph, you can see in the docs that the User_filter input type is used for the where:

So you can write a query that expects this input type as a variable, and then match it to the where argument

query filteredUsers($usersFilter: User_filter) { # define the variable
  users(where

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@mhpaler
Comment options

Answer selected by mhpaler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #278 on October 10, 2022 13:05.