Cycle API
CycleStatusChangelog
  • Cycle API
  • Introduction
    • About Cycle
    • Data model
  • The graphql API
    • How to start
    • Authentication
    • Node interface
    • Pagination
    • Webhooks
    • Limitations
    • Graphql Schema
    • Examples
  • Company
    • Company Attribute
    • List Company attributes by product
    • Create a company
    • Update a company attribute value
  • Practical use case: the feedback form
    • Create a feedback
    • Advanced: use your properties
Powered by GitBook
On this page
  1. The graphql API

Node interface

Any Cycle entity can be fetched through the node interface to help graphql clients to easily cache data.

PreviousAuthenticationNextPagination

Last updated 1 year ago

As you will discover in the graphql schema, most entities implement the Node interface. This is a common pattern that let you query those entities using the id as a parameter and some interface fragments to extract additional information specific to the type which conform to the node interface. More about this .

Node queries will always return a single entity from which you can drill down the graph.

query docNode {
    node(id: "<ID>") {
        ...on Doc {
            id
            title
        }
    }
}

As a starting point, you can use the me or the getProductBySlug query to get your first ids. Let's get the id of a product and fetch its doctypes with the node query. We will be using your product slug which is a unique identifier of your workspace/product that you can find after the /app/ part of the url from your browser.

query getProductBySlug {
    getProductBySlug(slug: "<slug>") {
        id
        slug
        name
    }
}

Then with the node query

query node {
    node(id: "<productId>") {
        ...on Product {
            doctypes {
                edges {
                    node {
                        id
                        name
                    }
                }
            }
        }
    }
}

In the returning type, we used some edges resolver which are part of our pagination strategy. You will read more about it in the next section.

here