Skip to content

Latest commit

 

History

History
110 lines (107 loc) · 1.36 KB

README.md

File metadata and controls

110 lines (107 loc) · 1.36 KB

GraphQL Example

  1. Install dependencies with npm install
  2. Run the server with node server.js
  3. Open the GraphiQL UI at http://localhost:3000/graphiql

Schemas

There are other schema files that demonstrate different things:

schema.js Default schema, just returns a value. Sample query:
query {
  serverStatus
}
schema1.js Plain query with resolvers
query {
  getUsers {
    name
    email
    age
  }
}
schema2.js Query With nested objects
query {
  getUsers {
    name
    email
    age
    posts {
      id
      title
    }
  }
}
schema3.js Query with parameters
query {
  getUser(name: "alex") {
    name
    email
    age
  }
}
schema4.js Query with Mutations
mutation{
  addUser(newUser: {name: "steve", email: "[email protected]"}) {
    name
    email
    age
  }
}

Or using Query with Variable parameters:
Query:

mutation addAUser($user: UserInput){
  addUser(newUser: $user ) {
    name
    email
    age
  }
}

Parameters:

{"user":{"name": "steve", "email": "[email protected]"}}