Is there any CRUD example with graphQL with NextJS?

I want to prepare a demo with the faunaDB with below features.

  • Listing of the collections
  • Search, filter, sorting, pagination
  • Add/Edit/Delete collection

Here is the schema for the collection

type ShopCollection {
  shop_collection_id: Int!
  title: String!
  type: String!
  base_rules: String!
  status: String!
  shop_domain: String!
}

But faunaDB GraphQL Playground give me a blank data
Here the query which I’m trying

# Write your query or mutation here
query getAllCollections {
  allShopCollections(_size: 10) {
    data {
      _id
      shop_domain
      shop_collection_id
    }
  }
}

Or please suggest any demo version of this combination

in the playground’s right side you should find a tab with the Docs on how to use the Create/Update/Delete on Graphql for your schema.

For filtering and sorting you’ll have to follow the tutorials on how to use Indexes and UDFs and the @resolve directive

Thanks for the reply!
Actually, I want a sample code for this. Becuase I already create a schema and fauna already generate a docs for me within the GraphQL Playground but as I told in the topic it’s return with the blank data

Here is the query result even data is exists

{
  "data": {
    "allShopCollections": {
      "data": []
    }
  }
}

I don’t see from your schema where you defined the allShopCollections query - can you share that?

You can also refer to the Vercel guestbook demo app from the Sample apps page. It uses both Next.js and GraphQL with Fauna.

Sorry,
Let me write here complete schema

type ShopCollection {
  shop_collection_id: Int!
  title: String!
  automated_max_products: Int!
  type: String!
  has_autoshffle: Boolean!
  base_rules: String!
  status: String!
  shop_domain: String!
  createdAt: Time!
  # _id: Generated by Fauna as each document's unique identifier
  # _ts: Timestamp generated by Fauna upon object updating
}

# A query named 'entries' which returns an array of ShopCollection objects
# Implicit arguments: _size (count) and _cursor (location within the Index)
type Query {
  entries: [ShopCollection!]
    @resolver(name: "listLatestCollections", paginated: true)
}

Here is the screenshot which having issue

Gotcha - thank you!

So this is happening because of the @resolver directive on the listLatestCollections query. What that does is tell Fauna to invoke a User-defined function (UDF) named listLatestCollections whenever the GraphQL query entries is called.

What the error message is telling you is that the listLatestCollections UDF hasn’t been implemented by you.

You should be able to get this working by removing @resolver(name: "listLatestCollections", from your entries query definition.

You could also implement the listLatestCollections UDF, but that’s beyond the scope of this topic.