ondiekelijah / Nodejs-GraphQL-tutorial

How to Get Started With Node.JS and GraphQL: Everything You Need to Know

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Node.js and GraphQL-tutorial

Setup instructions.

  1. Cloning the repo
    git clone https://github.com/ondiekelijah/Nodejs-GraphQL-tutorial.git
    cd Nodejs-GraphQL-tutorial
  2. Installing dependencies npm install
  3. Starting the server npm start

Playground - https://studio.apollographql.com/sandbox/explorer

Playground Queries & Mutations.

1. createEvent Operation

mutation {
  createEvent(input: {
      title: "PyCon KE"
      description: "The Pycon Edition of Kenya brings together software devs, startups, students, learning instutions and people passionate about python and its ecosystem."
      date: "2022-04-01"
      location: "Nairobi, Kenya"
      organizers: ["Python Nairobi"]
      time: "8:00"
      venue: "USIU, Nairobi"
    }
  ) {
    id
    title
    description
    date
    location
    time
    venue
    organizers
  }
}

2. events Operation

query QueryEvents {
  events {
    id
    title
    description
    date
    time
    venue
  }
}

3. event Operation

query QueryEvent($eventId: ID!) {
 event(id: $eventId) {
    id
    title
    description
    date
    time
    venue
 }
}

Variables

{
  "eventId": "your event ID"
}

4. updateEvent Operation

mutation {
  updateEvent(id: "57bf825f-7fe2-469a-91ff-61d56eb0cc07", input: {
      title: "PyCon KE 2022"
    }
  ) {
    title
  }
}

5. deleteEvent Operation

mutation {
  deleteEvent(id: "f6f205b1-1475-4ab8-8f42-804b477ca78a"
  ) 
}

About

How to Get Started With Node.JS and GraphQL: Everything You Need to Know


Languages

Language:JavaScript 100.0%