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

Can I filter on this field in queries? (GQL) #247

Open
tremby opened this issue Dec 7, 2022 · 0 comments
Open

Can I filter on this field in queries? (GQL) #247

tremby opened this issue Dec 7, 2022 · 0 comments

Comments

@tremby
Copy link

tremby commented Dec 7, 2022

I'm using GQL.

I'd like to query for entries where a craft-linkfield field is pointing to a particular destination.

More specifically, I want to find entries where the field is set to the "site" type, and points to a particular site ID.

Is this possible?

In the GQL explorer I see that there's an argument named after my link field (linkField for this example), and that it has the type [QueryArgument]. I can see QueryArgument mentioned a lot it Craft's docs but can't for the life of me find an actual explanation of what it is and how to use it. There's the Craft documentation page for GraphQL which mentions it as the type of a ton of different arguments but doesn't explain what it is, and then there's an API doc page for the class itself but that doesn't give any usage information either.

In searches I came across this comment, which suggests an array of QueryArgument can be things like ["not", 1, 2, 3], which gives some clues. I suspect it's documented elsewhere in a non-GQL context, but I haven't found it yet.

But regardless, no matter what I try to enter, whether strings or arrays of strings/numbers/booleans, I get this error:

The query for the field linkField refers to an unknown field '0'.

That happens in vendor/sebastianlenz/craft-utils/src/foreignField/ForeignField.php on line 318 (craft-utils is at version 3.0.3). Looking at that file, it seems it expects an associative array, but GQL does not let me pass an object here. Whether I pass a plain string or an array of strings/numbers/booleans, it arrives at this function as a number-indexed array. The code, meanwhile, expects the keys of the array to be field names.

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

No branches or pull requests

1 participant