-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
138 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { GraphQLClient } from '../esm/index.js' | ||
;(async function () { | ||
const endpoint = 'https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr' | ||
|
||
const graphQLClient = new GraphQLClient(endpoint, { | ||
headers: { | ||
authorization: 'Bearer MY_TOKEN' | ||
} | ||
}) | ||
|
||
const query = /* GraphQL */ ` | ||
{ | ||
Movie(title: "Inception") { | ||
releaseDate | ||
actors { | ||
name | ||
} | ||
} | ||
} | ||
` | ||
const data = await graphQLClient.request(query) | ||
console.log(JSON.stringify(data, undefined, 2)) | ||
})().catch((error) => console.error(error)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
;(global).fetch = require('fetch-cookie/node-fetch')(require('node-fetch')) | ||
const { GraphQLClient } = require('../../cjs/index.js') | ||
|
||
;(async function () { | ||
const endpoint = 'https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr' | ||
|
||
const graphQLClient = new GraphQLClient(endpoint, { | ||
headers: { | ||
authorization: 'Bearer MY_TOKEN' | ||
} | ||
}) | ||
|
||
const query = /* GraphQL */ ` | ||
{ | ||
Movie(title: "Inception") { | ||
releaseDate | ||
actors { | ||
name | ||
} | ||
} | ||
} | ||
` | ||
|
||
const data = await graphQLClient.rawRequest(query) | ||
console.log(JSON.stringify(data, undefined, 2)) | ||
})().catch((error) => console.error(error)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"type":"commonjs"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { request } from '../esm/index.js' | ||
;(async function () { | ||
const endpoint = 'https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr' | ||
|
||
const query = /* GraphQL */ ` | ||
{ | ||
Movie(title: "Inception") { | ||
releaseDate | ||
actors { | ||
fullname # "Cannot query field 'fullname' on type 'Actor'. Did you mean 'name'?" | ||
} | ||
} | ||
} | ||
` | ||
|
||
try { | ||
const data = await request(endpoint, query) | ||
console.log(JSON.stringify(data, undefined, 2)) | ||
} catch (error) { | ||
console.error(JSON.stringify(error, undefined, 2)) | ||
process.exit(1) | ||
} | ||
})().catch((error) => console.error(error)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { GraphQLClient } from '../esm/index.js' | ||
;(async function () { | ||
const endpoint = 'https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr' | ||
|
||
const graphQLClient = new GraphQLClient(endpoint, { | ||
credentials: 'include', | ||
mode: 'cors' | ||
}) | ||
|
||
const query = /* GraphQL */ ` | ||
{ | ||
Movie(title: "Inception") { | ||
releaseDate | ||
actors { | ||
name | ||
} | ||
} | ||
} | ||
` | ||
|
||
const data = await graphQLClient.request(query) | ||
console.log(JSON.stringify(data, undefined, 2)) | ||
})().catch((error) => console.error(error)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { rawRequest } from '../esm/index.js' | ||
;(async function () { | ||
const endpoint = 'https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr' | ||
|
||
const query = /* GraphQL */ ` | ||
{ | ||
Movie(title: "Inception") { | ||
releaseDate | ||
actors { | ||
name | ||
} | ||
} | ||
} | ||
` | ||
|
||
const { data, errors, extensions, headers, status } = await rawRequest(endpoint, query) | ||
console.log(JSON.stringify({ data, errors, extensions, headers, status }, undefined, 2)) | ||
})().catch((error) => console.error(error)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { request } from '../esm/index.js' | ||
;(async function () { | ||
const endpoint = 'https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr' | ||
|
||
const query = /* GraphQL */ ` | ||
query getMovie($title: String!) { | ||
Movie(title: $title) { | ||
releaseDate | ||
actors { | ||
name | ||
} | ||
} | ||
} | ||
` | ||
|
||
const variables = { | ||
title: 'Inception' | ||
} | ||
|
||
const data = await request(endpoint, query, variables) | ||
console.log(JSON.stringify(data, undefined, 2)) | ||
})().catch((error) => console.error(error)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters