menu button

Chapter 1: Projects

Get Protocols by Project

Once a user selects a project, they can retrieve all the documents (called protocols) associated with that project using getProtocolsByProjectSlug query


Get protocols by project

  • This operation returns a list of protocols for a specific project.
import axios from "axios";

export const GET_PROTOCOLS_BY_PROJECT = `
    query GetProtocolsByProjectSlug($slug: String!) {
        getProtocolsByProjectSlug(slug: $slug) {
            slug
            name
            date
            status
            editStage
            bucketAws
        }
    }
`;

const getProtocolsByProject = async (slug) => {
    try {
        const response = await axios({
            method: "POST",
            url: "https://your-graphql-endpoint.com/graphql",
            headers: {
                "Content-Type": "application/json",
                "x-api-key": process.env.VUE_APP_API_KEY,
            },
            data: JSON.stringify({
                query: GET_PROTOCOLS_BY_PROJECT,
                variables: { slug },
            }),
        });

        console.log('Protocols:', response.data.data.getProtocolsByProjectSlug);
    } catch (error) {
        console.error('Error fetching protocols:', error);
    }
};

// Example usage
getProtocolsByProject("your-project-slug");
  • Make sure to replace “your-project-slug” with the actual slug of the project you want to query.

After calling this query, the output will include all the protocols related to the specified project.

Have questions?

Still have questions? Talk to support.