Skip to content

Instantly share code, notes, and snippets.

@loriculberson
Last active November 4, 2022 02:35
Show Gist options
  • Save loriculberson/0b72c6b04ee0b1f64358adf1c08504f9 to your computer and use it in GitHub Desktop.
Save loriculberson/0b72c6b04ee0b1f64358adf1c08504f9 to your computer and use it in GitHub Desktop.

Backend

Vocabulary:

  • GraphQL: a query language that allows us to build even complex queries quickly and concisely, helping to make sure our queries fetch data -- and only the data we need -- quickly.

  • Apollo Sandbox: an Apollo Studio Explorer tool and is a great way to to visually explore how GraphQL can be used to request and fetch data while in development. (Not a production tool). We create queries here to fetch data. Query looks like:

query classes{
  classes {
    name
  }
}

  • Apollo server: a type of GraphQL server that uses a schema to describe the shape of your available data.

  • typeDefs:

    (1) defines fields on a database record (like the schema)

    (2) queries: functions that retrieve data - GET

    (3) mutations: functions to modify data - POST/DELETE/UPDATE

  • resolvers:

    (1) function definitions where we make db calls

Queries in Apollo Sandbox

query GetAllUsers {
  getAllUsers {
    email
  }
}

Mutations

mutation {
 createUser (name: "Sam", email: "mike@email.com", age: 30) {
   name
   email
   age
 }
}

image

Resources:

Frontend

Vocabulary:

Apollo Client: a library that allows us to handle data using the GraphQL on the front end.

useQuery image

useMutation image

cache: Apollo Client stores the results of your GraphQL queries in a local, normalized, in-memory cache. This enables Apollo Client to respond almost immediately to queries for already-cached data, without even sending a network request. image

Resources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment