Giter Site home page Giter Site logo

bootcamp-graphql-practice's Introduction

Bootcamp GraphQL Practice

This repository contains a partially complete backend built off the starter code we'll be using next week in our final projects. It already contains full completed migrations, seed data, and models, so first get your database up and running (npm run migrations && npm run seed). Check out the data in Postico or DBeaver to get a sense of what it looks like.

There are 4 tables: books, authors, publishers, and addresses. There is a one-to-one relation between authors & books and publishers & books (each book has a single author and a single publisher). There is also a one-to-one relation between authors & addresses and publishers & addresses (each author and publisher has an address). Your goal for the day is to complete the GraphQL portion of this project.

Day 8 AM: GraphQL TypeDefs

The TypeDefs define the types and shapes of data that the client (frontend) can see. Under src/graphql/typeDefs.js, define the TypeDefs for this project. It should contain at least 3 queries and 2 mutations, but they can do whatever you'd like. You should aim to declare at least 4 types and 2 inputs.

Day 8 PM: GraphQL Resolvers

Now that we've defined a TypeDefs for our project, we need to define the 'resolvers' to tell GraphQL how to 'fulfill' our Queries and Mutations. Inside these resolvers is where we'll use all the power of Objection.js that we learned yesterday to manipulate/fetch our database data. You can get started writing your resolvers under src/graphql/Mutation and src/graphql/Query. An example resolver has been written under .../Query/Welcome.js.

You should create separate files to divide up your resolvers by 'type', e.g. in another project you might define a User.js file under both .../Query and .../Mutation. The former would contain resolvers for all Queries related to Users (getUserById, getAllUsers), while the latter would handle all Mutations related to Users (createUser, editUserInfo). How might you divide up your Mutations/Queries for this project?

Make sure that you write resolvers to completely satisfy your TypeDefs. This includes all subresolvers related to the types you define. For instance, in the FaceBook example we would need to define subresolvers on the User type for friends and posts.

bootcamp-graphql-practice's People

Contributors

laurenc8 avatar pkpbynum avatar charlesonesti avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.