in src/desktop/gitlab/gitlab_service.ts [271:301]
async getSnippets(namespaceWithPath: string, afterCursor?: string): Promise<GqlSnippet[]> {
const options: GetSnippetsQueryOptions = {
namespaceWithPath,
afterCursor,
};
const result = await this.#apiClient.graphqlRequest<GetSnippetsQueryResult>(
queryGetSnippets,
options,
);
const { project } = result;
// this can mean three things: project doesn't exist, user doesn't have access, or user credentials are wrong
// https://gitlab.com/gitlab-org/gitlab/-/issues/270055
if (!project) {
throw new Error(
`Project ${namespaceWithPath} was not found. You might not have permissions to see it.`,
);
}
const snippets = project.snippets.nodes;
// each snippet has to contain projectId so we can make REST API call for the content
const snippetsWithProject = snippets.map(sn => ({
...sn,
projectId: project.id,
}));
return project.snippets.pageInfo?.hasNextPage
? [
...snippetsWithProject,
...(await this.getSnippets(namespaceWithPath, project.snippets.pageInfo.endCursor)),
]
: snippetsWithProject;
}