Skip to content

Instantly share code, notes, and snippets.

@bradtraversy
Created June 2, 2022 17:37
Show Gist options
  • Star 55 You must be signed in to star a gist
  • Fork 37 You must be signed in to fork a gist
  • Save bradtraversy/fc527bc9a4659ab8de8e8066f3498723 to your computer and use it in GitHub Desktop.
Save bradtraversy/fc527bc9a4659ab8de8e8066f3498723 to your computer and use it in GitHub Desktop.
GraphQL Queries & Mutations

GraphQL Queries & Mutations

These are the GraphQL queries and mutations for the YouTube course.

Get names of all clients

{
  clients {
    name
  }
}

Get a single client name and email

{
  client(id: 1) {
    name
    email
  }
}

Get name and status of all projects

{
  projects {
    name
    status
  }
}

Get a single project name, description along with the client name and email

{
  project(id: 1) {
    name
    description,
    client {
      name
      email
    }
  }
}

Create a new client and return all data

mutation {
  addClient(name: "Tony Stark", email: "ironman@gmail.com", phone: "955-365-3376") {
    id
    name
    email
    phone
  }
}

Delete a client and return id

mutation {
  deleteClient(id: 1) {
    id
  }
}

Create a new project and return name and description

mutation {
  addProject(name: "Mobile App", description: "This is the project description", status: "new", clientId: "1") {
   name
   description
  }
}

Update a project status and return name and status

mutation {
  updateProject(status: "completed") {
   name
   status
  }
}
@jme-sull
Copy link

On the addProject mutation - no quotes needed around "new"

@xandert93
Copy link

missing the ID on the last update project mutation!

@jksaWork
Copy link

That Is Imazing Work Thank you alot

@andz89
Copy link

andz89 commented Aug 17, 2023

Nice work brad!

@Olasunkanmi56
Copy link

Thank you brad

@nikhilbhatt10798
Copy link

Thanks, brad!

@jamesryan-dev
Copy link

Thank you 🙏

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