feat: start exercise 3

This commit is contained in:
Kristof Van Miegem 2019-02-07 11:33:56 +01:00
parent 45f7debb77
commit 281ea4112a
1 changed files with 11 additions and 15 deletions

View File

@ -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