Skip to content

jesperancinha/guitar-shop

Repository files navigation

Making a query

Query examples

Get all guitars

query getGuitar {
  guitarById(id: 1) {
    id
    brand
    model
    owner {
      id
      firstName
      lastName
    }
  }
}
curl -X POST http://localhost:8080/graphql \
  -H "Content-Type: application/json" \
  -d '{
        "query": "query getGuitar { guitarById(id: 1) { id brand model owner { id firstName lastName } } }"
      }'
query getGuitar {
  guitarById(id: 1) {
    id
    model
    owner {
      id
      lastName
    }
  }
}
curl -X POST http://localhost:8080/graphql \
  -H "Content-Type: application/json" \
  -d '{"query":"{  allUsers { id name age } }"}'
query getOwner {
  ownerById(id: 1) {
      id
      lastName
  }
}
curl -X POST http://localhost:8080/graphql \
  -H "Content-Type: application/json" \
  -d '{
        "query": "query getOwner { ownerById(id: 1) { id lastName } }"
      }'

All users

mutation {
  createUser(name: "Black Raven", age: 30) {
    id
    name
    age
  }
}
query {
  allUsers {
    id
    name
    age
  }
}
curl -X POST http://localhost:8080/graphql \
  -H "Content-Type: application/json" \
  -d '{
        "query": "query allUsers { id name age }"
      }'

Resources

About me

GitHub followers