-
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): document anyware (#1093)
- Loading branch information
1 parent
031503f
commit cb7cf1f
Showing
19 changed files
with
451 additions
and
124 deletions.
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,14 @@ | ||
/** | ||
* This example shows how to configure output to approximate the traditional GraphQL ExecutionResult type. | ||
*/ | ||
|
||
import { Graffle, Preset } from '../../src/entrypoints/main.js' | ||
import { show } from '../$/show.js' | ||
|
||
const graffle = Graffle.create({ | ||
output: Preset.traditionalGraphqlOutput, | ||
}) | ||
|
||
const result = await graffle.rawString({ document: `{ query { thisWillError } }` }) | ||
|
||
show(result) |
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
38 changes: 38 additions & 0 deletions
38
examples/__outputs__/20_output/output_preset__standard-graphql.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,38 @@ | ||
/some/path/to/runPipeline.ts:84 | ||
return new ContextualError(message, { hookName: signal.hookName, source: signal.source }, signal.error) | ||
^ | ||
|
||
|
||
ContextualError: There was an error in the core implementation of hook "exchange". | ||
at runPipeline (/some/path/to/runPipeline.ts:XX:XX) | ||
at async runPipeline (/some/path/to/runPipeline.ts:XX:XX) | ||
at async runPipeline (/some/path/to/runPipeline.ts:XX:XX) | ||
... 3 lines matching cause stack trace ... | ||
at async Object.raw (/some/path/to/client.ts:XX:XX) | ||
at async Proxy.rawString (/some/path/to/client.ts:XX:XX) | ||
at async <anonymous> (/some/path/to/output_preset__standard-graphql.ts:XX:XX) { | ||
context: { hookName: 'exchange', source: 'implementation' }, | ||
[cause]: TypeError: Failed to parse URL from undefined | ||
at new Request (node:internal/deps/undici/undici:XX:XX) | ||
at Object.run (/some/path/to/core.ts:XX:XX) | ||
... 6 lines matching cause stack trace ... | ||
at async runRaw (/some/path/to/client.ts:XX:XX) | ||
at async Object.raw (/some/path/to/client.ts:XX:XX) { | ||
[cause]: TypeError: Invalid URL | ||
at new URL (node:internal/url:XX:XX) | ||
at new Request (node:internal/deps/undici/undici:XX:XX) | ||
at Object.run (/some/path/to/core.ts:XX:XX) | ||
at runHook (/some/path/to/runHook.ts:XX:XX) | ||
at runPipeline (/some/path/to/runPipeline.ts:XX:XX) | ||
at runPipeline (/some/path/to/runPipeline.ts:XX:XX) | ||
at async runPipeline (/some/path/to/runPipeline.ts:XX:XX) | ||
at async Object.run (/some/path/to/main.ts:XX:XX) | ||
at async run (/some/path/to/client.ts:XX:XX) | ||
at async runRaw (/some/path/to/client.ts:XX:XX) { | ||
code: 'ERR_INVALID_URL', | ||
input: 'undefined' | ||
} | ||
} | ||
} | ||
|
||
Node.js vXX.XX.XX |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { traditionalGraphqlOutput } from '../layers/6_client/Settings/Config.js' |
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
19 changes: 19 additions & 0 deletions
19
tests/examples/20_output/output_preset__standard-graphql.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,19 @@ | ||
// @vitest-environment node | ||
|
||
// WARNING: | ||
// This test is generated by scripts/generate-example-derivatives/generate.ts | ||
// Do not modify this file directly. | ||
|
||
import { expect, test } from 'vitest' | ||
import { runExample } from '../../../scripts/generate-examples-derivatives/helpers.js' | ||
|
||
test(`output_preset__standard-graphql`, async () => { | ||
const exampleResult = await runExample(`./examples/20_output/output_preset__standard-graphql.ts`) | ||
// Examples should output their data results. | ||
const exampleResultMaybeEncoded = exampleResult | ||
// 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(exampleResultMaybeEncoded).toMatchFileSnapshot( | ||
`../../../examples/__outputs__/20_output/output_preset__standard-graphql.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 |
---|---|---|
@@ -1 +1 @@ | ||
<p class="ExampleLinks">Examples <span class="ExampleLinksTitleSeparator">-></span> <a href="../../examples/output/default">Default</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/output/envelope">Envelope</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/output/envelope-error">Envelope Error</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/output/envelope-error-throw">Envelope Error Throw</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/output/return-error">Return Error</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/output/return-error-execution">Return Error Execution</a></p> | ||
<p class="ExampleLinks">Examples <span class="ExampleLinksTitleSeparator">-></span> <a href="../../examples/output/default">Default</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/output/envelope">Envelope</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/output/envelope-error">Envelope Error</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/output/envelope-error-throw">Envelope Error Throw</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/output/standard-graphql">Standard Graphql</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/output/return-error">Return Error</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/output/return-error-execution">Return Error Execution</a></p> |
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 @@ | ||
<p class="ExampleLinks">Examples <span class="ExampleLinksTitleSeparator">-></span> <a href="../../examples/output/standard-graphql">Standard Graphql</a></p> |
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 @@ | ||
<p class="ExampleLinks">Examples <span class="ExampleLinksTitleSeparator">-></span> <a href="../../examples/output/standard-graphql">Standard Graphql</a></p> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
aside: false | ||
--- | ||
|
||
# Standard Graphql | ||
|
||
This example shows how to configure output to approximate the traditional GraphQL ExecutionResult type. | ||
|
||
<!-- dprint-ignore-start --> | ||
```ts twoslash | ||
import { Graffle, Preset } from 'graffle' | ||
|
||
const graffle = Graffle.create({ | ||
output: Preset.traditionalGraphqlOutput, | ||
}) | ||
|
||
const result = await graffle.rawString({ document: `{ query { thisWillError } }` }) | ||
|
||
console.log(result) | ||
``` | ||
<!-- dprint-ignore-end --> | ||
|
||
#### Outputs | ||
|
||
<!-- dprint-ignore-start --> | ||
```txt | ||
/some/path/to/runPipeline.ts:84 | ||
return new ContextualError(message, { hookName: signal.hookName, source: signal.source }, signal.error) | ||
^ | ||
ContextualError: There was an error in the core implementation of hook "exchange". | ||
at runPipeline (/some/path/to/runPipeline.ts:XX:XX) | ||
at async runPipeline (/some/path/to/runPipeline.ts:XX:XX) | ||
at async runPipeline (/some/path/to/runPipeline.ts:XX:XX) | ||
... 3 lines matching cause stack trace ... | ||
at async Object.raw (/some/path/to/client.ts:XX:XX) | ||
at async Proxy.rawString (/some/path/to/client.ts:XX:XX) | ||
at async <anonymous> (/some/path/to/output_preset__standard-graphql.ts:XX:XX) { | ||
context: { hookName: 'exchange', source: 'implementation' }, | ||
[cause]: TypeError: Failed to parse URL from undefined | ||
at new Request (node:internal/deps/undici/undici:XX:XX) | ||
at Object.run (/some/path/to/core.ts:XX:XX) | ||
... 6 lines matching cause stack trace ... | ||
at async runRaw (/some/path/to/client.ts:XX:XX) | ||
at async Object.raw (/some/path/to/client.ts:XX:XX) { | ||
[cause]: TypeError: Invalid URL | ||
at new URL (node:internal/url:XX:XX) | ||
at new Request (node:internal/deps/undici/undici:XX:XX) | ||
at Object.run (/some/path/to/core.ts:XX:XX) | ||
at runHook (/some/path/to/runHook.ts:XX:XX) | ||
at runPipeline (/some/path/to/runPipeline.ts:XX:XX) | ||
at runPipeline (/some/path/to/runPipeline.ts:XX:XX) | ||
at async runPipeline (/some/path/to/runPipeline.ts:XX:XX) | ||
at async Object.run (/some/path/to/main.ts:XX:XX) | ||
at async run (/some/path/to/client.ts:XX:XX) | ||
at async runRaw (/some/path/to/client.ts:XX:XX) { | ||
code: 'ERR_INVALID_URL', | ||
input: 'undefined' | ||
} | ||
} | ||
} | ||
Node.js vXX.XX.XX | ||
``` | ||
<!-- dprint-ignore-end --> |
Oops, something went wrong.