Skip to content

Latest commit

 

History

History
124 lines (110 loc) · 1.36 KB

EXAMPLES.md

File metadata and controls

124 lines (110 loc) · 1.36 KB

Example Queries

Get list of authors (it will return only first 10 authors!):

query {
  authors {
    edges {
      node {
        id
        _id
        firstName
        lastName
      }
    }
  }
}

Filter authors based of first name, also return total number of such authors:

query {
  authors(firstName: "Robert") {
    totalCount
    edges {
      node {
        id
        _id
        firstName
        lastName
      }
    }
  }
}

Order authors by first name and last name:

query {
  authors(orderBy:[
    {
      field:FIRST_NAME
      direction:ASC
    }
    {
      field:LAST_NAME
      direction:ASC
    }
  ]) {
    edges {
      cursor
      node {
        _id
        firstName
        lastName
      }
    }
  }
}

Get name of author with ID = 4:

query {
  author(id: 4) {
    id
    _id
    firstName
    lastName
  }
}

Get list of quotes:

query {
  quotes {
    edges {
      node {
        id
        _id
        quote
      }
    }
  }
}

Create new author:

mutation {
  createAuthor(input:{
    firstName:"Kent"
    lastName:"Beck"
  }) {
    id
    _id
    firstName
    lastName
  }
}

Update existing author:

mutation {
  updateAuthor(input:{
    id: 1
    firstName: "JOHN"
    lastName: "JOHNSON"
  }) {
    id
    _id
    firstName
    lastName
  }
}