-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(docs): bette organize http transport examples
- Loading branch information
1 parent
46abb09
commit f282913
Showing
42 changed files
with
184 additions
and
126 deletions.
There are no files selected for viewing
14 changes: 0 additions & 14 deletions
14
examples/transport-http|transport-http_RequestInput.output.txt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
4 changes: 4 additions & 0 deletions
4
...es/transport-http|transport-http_fetch.ts → ...ort-http_extension_fetch__custom-fetch.ts
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
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
4 changes: 4 additions & 0 deletions
4
...transport-http_headers__dynamicHeaders.ts → ...http_extension_headers__dynamicHeaders.ts
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
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
examples/transport-http|transport-http_headers__dynamicHeaders.output.txt
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
examples/transport-http|transport-http_headers_raw__headers.output.txt
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,6 @@ | ||
---------------------------------------- SHOW ---------------------------------------- | ||
Headers { | ||
accept: 'application/graphql-response+json; charset=utf-8, application/json; charset=utf-8', | ||
'content-type': 'application/json', | ||
'x-from-raw': 'true' | ||
} |
32 changes: 32 additions & 0 deletions
32
examples/transport-http|transport-http_headers_raw__headers.ts
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,32 @@ | ||
/** | ||
* This example shows how to use the `transport` configuration to control request headers. Notice how empty string headers unset previously set headers. | ||
*/ | ||
import { Graffle } from '../src/entrypoints/main.js' | ||
import { show } from './$/helpers.js' | ||
import { publicGraphQLSchemaEndpoints } from './$/helpers.js' | ||
|
||
const graffle = Graffle | ||
.create({ | ||
schema: publicGraphQLSchemaEndpoints.SocialStudies, | ||
transport: { | ||
headers: { | ||
// todo: authorization header not showing up in final output! | ||
authorization: `Bearer MY_TOKEN`, | ||
'x-something-to-unset': `true`, | ||
}, | ||
raw: { | ||
headers: { | ||
'x-from-raw': `true`, | ||
}, | ||
}, | ||
}, | ||
}) | ||
.with({ | ||
transport: { headers: { 'x-something-to-unset': `` } }, | ||
}) | ||
.use(async ({ exchange }) => { | ||
show(exchange.input.request.headers) | ||
return exchange() | ||
}) | ||
|
||
await graffle.rawString({ document: `{ languages { code } }` }) |
48 changes: 0 additions & 48 deletions
48
examples/transport-http|transport-http_method-get.output.test.txt
This file was deleted.
Oops, something went wrong.
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
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
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
24 changes: 24 additions & 0 deletions
24
tests/examples/transport-http|transport-http_extension_headers__dynamicHeaders.test.ts
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,24 @@ | ||
// @vitest-environment node | ||
|
||
// WARNING: | ||
// This test is generated by scripts/generate-example-derivatives/generate.ts | ||
// Do not modify this file directly. | ||
|
||
import { execaCommand } from 'execa' | ||
import stripAnsi from 'strip-ansi' | ||
import { expect, test } from 'vitest' | ||
import { encode } from '../../examples/transport-http_headers__dynamicHeaders.output-encoder.js' | ||
|
||
test(`transport-http|transport-http_extension_headers__dynamicHeaders`, async () => { | ||
const result = await execaCommand( | ||
`pnpm tsx ./examples/transport-http|transport-http_extension_headers__dynamicHeaders.ts`, | ||
) | ||
expect(result.exitCode).toBe(0) | ||
// Examples should output their data results. | ||
const exampleResult = encode(stripAnsi(result.stdout)) | ||
// If ever outputs vary by Node version, you can use this to snapshot by Node version. | ||
// const nodeMajor = process.version.match(/v(\d+)/)?.[1] ?? `unknown` | ||
await expect(exampleResult).toMatchFileSnapshot( | ||
`../.././examples/transport-http|transport-http_extension_headers__dynamicHeaders.output.test.txt`, | ||
) | ||
}) |
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
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
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
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
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
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
Oops, something went wrong.