With our GraphQL schema in hand, we can create a full-fledged Fauna database. We'll import our GraphQL schema into a newly created database and explore the mutations and queries that were generated for us by creating and searching for a shop.
Shadid Haque: [0:00] Let's head over to dashboard.fauna.com. We will select Create Database to create a new database. I'm going to name my database, myvendorapp. I'm going to choose the classic region.
[0:14] Next, we are going to select the GraphQL tab. Then we're going to select Import Schema. We will upload the schema file that we created in the previous lesson. Once the schema is uploaded, we will be prompted with a GraphQL playground.
[0:33] Let's go ahead and take a look at the collection tab. Notice that product and shop collection has been created. Let's head back to GraphQL. If we review the docs tab, you'll see all the available mutations and queries. Fauna auto-generated these queries and mutations from our schema.
[0:52] Let's run this createShop mutation to create a new shop from our playground. We will start with the mutation keyword and then name of the mutation. In this case, it is going to be createShop.
[1:04] Then, we specify the input data. We give it a name, description, coverIMG. For products, it's just going to be an empty array for now, and ownerID, which can be any random strings for this example. For the return sub-selection, I'm just going to specify ID.
[1:28] Let's go ahead and run this. It successfully created a new shop and returned the ID of that shop. We can verify this by navigating to collections and shop collection. We have a new record here.
[1:46] Let's head back to our GraphQL playground. We'll create a new tab by clicking the plus button. Here we will run another query. This query will be findShopByID. We will pass in the ID of the shop that we just created.
[2:03] In the sub-selections, I'm going to have ID, description, name, ownerID. For products, we also have to specify the sub-selection for products because it's another type. I'm just going to say ID. Let's run this. We get our shop back.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!