-
TL;DRI built a plugin that gives users a space to leave feedback (
What's workingI'm using the approach defined in the Extending GraphQL docs (https://craftcms.com/docs/3.x/extend/graphql.html#arguments) to create some custom arguments. For instance, I'm using the following query successfully in my JS:
In the above query,
My QuestionIf possible, I'd like to create a custom Argument with some conditional logic in it. I'm hoping to only return the Feedback items where a user has entered a value in the
The datapoint Is this possible? Is there a better way to approach this like maybe in my GQL query? Help. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Depending on how you have set things up, but most likely you have a custom resolver set up since it's a custom element, so it's entirely up to you what you do with the arguments that are passed in. For example, the entry resolver knows that any arguments are going to have matching methods on the element query, so it just passes those values onwards. You likely have a custom element query class, so it's mostly a matter of implementing this on that class and then passing the value in the resolver to the element query. |
Beta Was this translation helpful? Give feedback.
-
YOOOOO! Got this working like a dream. Worked with @AugustMiller to figure out a solution to add the custom query (computed value) to my ElementQuery and then I was able to add the Argument to my plugin's GQL setup. Very stoked. The ElementQuery approach: And then I added it to my |
Beta Was this translation helpful? Give feedback.
YOOOOO! Got this working like a dream.
Worked with @AugustMiller to figure out a solution to add the custom query (computed value) to my ElementQuery and then I was able to add the Argument to my plugin's GQL setup. Very stoked.
The ElementQuery approach:
https://gist.github.com/AugustMiller/7a0c5f87019f5d959b0d6001ba0be9b0
And then I added it to my
src/gql/interfaces
andsrc/gql/arguments
files following the methods in the Extending GQL docs: