- Install dependencies with
npm install
- Run the server with
node server.js
- Open the GraphiQL UI at
http://localhost:3000/graphiql
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: mutation addAUser($user: UserInput){
addUser(newUser: $user ) {
name
email
age
}
} Parameters: {"user":{"name": "steve", "email": "[email protected]"}} |