Node interface

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

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 here.

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.

Last updated