How to query based on fields and not filters in GraphQL

New Member
1 0 0

Is there a way to query using an object's fields rather than its filters? My intent is to query all product variants with a specific metafield, but right now I only know how to just grab every variant, most of which will not be useful. productVariant has many fields that look useful for this, but I'm not sure if they're usable and how they work. I'd expect this query to only return variants that are listed as Active in shopify:

query getMetafields {
productVariants(first: 249, query:"availableForSale:true"){
edges {
node {
metafield(namespace: "x", key: "y") {

This returns the same results whether I put false or true, however. I'd also expect something like this query to work:

productVariants(first: 249, query:"!(metafields(namespace: 'x', key: 'y'):null)"){

Which means that either my understanding of the syntax is wrong, or that only filters can be used in the query (which I imagine can't be true, since they're incredibly limited). If anyone knows how to accomplish this, please let me know! Thanks.