Skip to content

josemateuss/node-graphql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphQL Studies

This repo was created with focus at my studies about GraphQL.

graphql nodejs

Stack

  • Node
    • Apollo Server (spec-compliant GraphQL server)
    • JSON Server (to simulate an API Rest)
  • GraphQL
  • SQLite (still working in another datasource)

Setup

# Cloning project
git clone https://github.com/josemateuss/node-graphql.git
cd node-graphql

# Installing dependencies
npm install

Running Project

# Running JSON Server in http://localhost:3000
npx json-server --watch api/data/data.json

# Running Project in http://localhost:4000 (GraphQL Playground)
npm start

GraphQL Queries and Mutations

Find all users:

query {
  users {
    name
    active
    email
    age
    height
    role {
      type
    }
    phones {
      number
    }
  }
}

Find a specific user:

query {
  user(id: 7) {
    name
    active
    email
    age
    height
    role {
      type
    }
    phones {
      number
    }
  }
}

Register an user:

mutation {
  registerUser(
    user: {
      name: "José Mateus"
      active: true
      email: "[email protected]"
      age: 25
      height: 174
      role: COORDINATION
      phones: [{ number: "(61) 99432-1000" }, { number: "(61) 3333-4444" }]
      createdAt: "2020-10-21"
    }
  ) {
    name
  }
}

Update an user:

mutation {
  updateUser(
    id: 7
    user: {
      name: "José Mateus"
      active: true
      email: "[email protected]"
      age: 25
      height: 174
      role: STUDENT
      phones: [{ number: "(61) 99432-1000" }, { number: "(61) 99999-9999" }]
    }
  ) {
    code
    message
    user {
      name
    }
  }
}

Delete an user:

mutation {
  deleteUser(id: 7) {
    code
    message
  }
}

About

Repository with focus in my studies about GraphQL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published