From 281ea4112a62fd9a6f0e86d5a22dc9c88a4823c7 Mon Sep 17 00:00:00 2001 From: Kristof Van Miegem Date: Thu, 7 Feb 2019 11:33:56 +0100 Subject: [PATCH] feat: start exercise 3 --- src/index.js | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/index.js b/src/index.js index 2a1292a..a02f211 100644 --- a/src/index.js +++ b/src/index.js @@ -11,24 +11,20 @@ const typeDefs = require('./typeDefs'); // a store, we get a list of products (query) of that store. // We pick some products, pick a quantity, and we make a reservation (mutation) -// 🏪 Exercise 2 +// 🏪 Exercise 3 // -------------- -// Creating a mutation. +// Now we want to display the products for a store, we can select the quantity of each product, +// and make a reservation. -// 1) Create a type definition for the Mutation `createStore`, to create a store. -// Create an input type `StoreInput`, and use it as first argument of `createStore`. -// 2) Create a resolver function for the Mutation `createStore`. -// 3) Use `yup` in the resolver function to validate the input. (https://github.com/jquense/yup) -// 4) Create a service layer. Create a file `storeService.js` and put all business -// logic and data base logic in the service layer. -// This exercise is focussed on GraphQL but in real-life, middleware will -// validate if the user is authorized (e.g. check the Authorization header). -// Afterwards the resolver function will validate the input and call the service layer. -// 5) Try out the GraphQL mutation in the GraphQL Playground (🚀 http://localhost:4000/) -// 6) Query the stores, and check if the new store is in the list. -// 7) Extend the store with an address (street, number, postalCode, city) and create a fragment -// to query it. +// 1) Create a Query `store` to retrieve a store by id. Extend the data store to find the right store. +// 2) Create a list of products with a reference (storeId). +// 3) Extend the Store type with a list of products. A product has a price, name and description. +// `products` becomes a field of the store. Add a resolver function to get the products of a store. +// 4) Go to the GraphQL Playground and use a directive to query a store with or without products, +// name the variable `withProducts`. + +// 1) Check: https://graphql.org/learn/queries/#variables // In the most basic sense, the ApolloServer can be started // by passing type definitions (typeDefs) and the resolvers