Search code examples
reactjsgraphqlnext.jsprismaprisma-graphql

How you build GraphQL queries using (where:)


I everyone,

I hope you are all safe, healthy, and happy in these scary times. I am working on an e-commerce website based on Next.js Prisma, Yoga, and GraphQL.

I am having trouble building a query to see if a Type field is true on an item in my DB and only show those sandwiches on the homepage.

On the frontend, I have tried:

const FEATURED_SANDWICH_QUERY = gql`
  query FEATURED_SANDWICH_QUERY {
    sandwiches(orderBy: featured_DESC) {
      id
      image
      title
      description
    }
  }
`;

and sandwiches(where: {featured_contains: true}) and sandwiches(where: {featured: true})

So far I am getting nothing returned or others errors

Here are the links to the backend query, data model, and schema. I am new at this, what am I doing wrong building the query? Thanks For your help

Query.js

datamodel.graphql

schema.graphql

Homepage.js


Solution

  • sandwiches(where: {featured: true}) should work as per your schema. Could you check again?