MCPcopy Create free account
hub / github.com/freeCodeCamp/freeCodeCamp / queryGraphQL

Function queryGraphQL

tools/daily-challenges/helpers.ts:7–25  ·  view source on GitHub ↗
(query: string)

Source from the content-addressed store, hash-verified

5
6// Query graphQL - note that the main client needs to be running to query the challenges
7export async function queryGraphQL(query: string) {
8 const response = await fetch(GRAPHQL_ENDPOINT, {
9 method: 'POST',
10 headers: {
11 'Content-Type': 'application/json'
12 },
13 body: JSON.stringify({ query })
14 });
15
16 const json = (await response.json()) as QueryResult;
17
18 if (!json?.data?.allChallengeNode?.edges?.length) {
19 throw new Error(
20 'Failed to find any challenges with GraphQL query. The client needs to be running'
21 );
22 }
23
24 return json;
25}
26
27export async function fetchChallenges(language: 'javascript' | 'python') {
28 const query = `

Callers 1

fetchChallengesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected