MCPcopy Create free account
hub / github.com/cardstack/cardstack / query

Function query

packages/cardpay-sdk/sdk/utils/graphql.ts:16–39  ·  view source on GitHub ↗
(
  networkOrWeb3: string | Web3,
  graphQLQuery: string,
  variables?: { [varName: string]: string | number }
)

Source from the content-addressed store, hash-verified

14 variables?: { [varName: string]: string | number }
15): Promise<{ data: any }>;
16export async function query(
17 networkOrWeb3: string | Web3,
18 graphQLQuery: string,
19 variables?: { [varName: string]: string | number }
20): Promise<{ data: any }> {
21 let subgraphURL: string;
22 if (typeof networkOrWeb3 === 'string') {
23 subgraphURL = await getConstant('subgraphURL', networkOrWeb3);
24 } else {
25 subgraphURL = await getConstant('subgraphURL', networkOrWeb3);
26 }
27 let response = await fetch(subgraphURL, {
28 method: 'POST',
29 headers: {
30 'Content-Type': 'application/json', //eslint-disable-line @typescript-eslint/naming-convention
31 Accept: 'application/json', //eslint-disable-line @typescript-eslint/naming-convention
32 },
33 body: JSON.stringify({
34 query: graphQLQuery,
35 variables,
36 }),
37 });
38 return await response.json();
39}

Callers 3

viewSafeMethod · 0.90
viewMethod · 0.90

Calls 1

getConstantFunction · 0.90

Tested by

no test coverage detected