python graphql term search

Topic summary

Issue: A Python GraphQL product search against Shopify returns all products instead of filtering by the search term.

Details:

  • The query defines a variable $terms and uses it in products(first:250, query:$terms).
  • The execution passes variables={“query”: terms}, which does not match the declared variable name (should align with “terms”).
  • The user wants the search term to match across all document fields.

Context:

  • A code snippet is central to understanding the problem.

Status:

  • No resolution or replies yet; the thread remains open with the key question of why the filter is not applied and how to search across all fields.
Summarized with AI on February 11. AI used: gpt-5.

I am trying to make a query term search with python, this is the code:

query = """
                query($terms: String) {
                products(first:250, query:$terms) {
                    pageInfo {
                    hasNextPage
                    }
                    edges {
                    cursor
                    node {
                        id
                        handle
                        tags
                    }
                    }
                }
                }        
            """#.format(tag)
            return shopify.GraphQL().execute(query, variables={"query": terms})

I get all the products, the query doesn’t filter them.

I want to find the term in all the document fields.

What’s wrong?