Fetching data

Last updated on
14 May 2018

Nodes

Fetching a node by id

query {
  nodeById(id: "661") {
    entityLabel
    entityType

    entityRendered
  }
}

Fetching nodes

This very simple query results into the number of nodes. This is the minimal query when autocomplete using the GraphiQL on /graphql/explorer

query {
  nodeQuery {
    count
  }
}

Using fragments

To get Node (entity) or even Article (bundle) you can use fragments to 'drilldown' into their particular fields.

query {
  nodeQuery {
    count
    entities {
      entityLabel
      entityType
      ... on Node {
        title
      }
      ... on NodeArticle {
        fieldImage {
          title
          width
          height
          url
        } 
      }
    }
  }
}

Filter

See project documentation filter

{
  nodeQuery (filter: {conditions: {field: "type", value: "article", operator: EQUAL}}) {
....
  }
}

Alias

query {
  nodeQuery()  {
    entities {
      entityLabel
      entityType

      # http://graphql.org/learn/queries/#aliases 
      canDelete: entityAccess(operation: "delete")
      canUpdate: entityAccess(operation: "update")
    }
  }
}

Help improve this page

Page status: No known problems

You can: