-
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.
fix: raw variables inference (#1077)
- Loading branch information
1 parent
6bbe63f
commit 16377bb
Showing
52 changed files
with
581 additions
and
272 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,27 @@ | ||
---------------------------------------- SHOW ---------------------------------------- | ||
{ | ||
data: { | ||
continents: [ | ||
{ name: 'Africa' }, | ||
{ name: 'Antarctica' }, | ||
{ name: 'Asia' }, | ||
{ name: 'Europe' }, | ||
{ name: 'North America' }, | ||
{ name: 'Oceania' }, | ||
{ name: 'South America' } | ||
] | ||
}, | ||
errors: undefined, | ||
extensions: undefined, | ||
response: Response { | ||
status: 200, | ||
statusText: '', | ||
headers: DYNAMIC_VALUE, | ||
body: ReadableStream { locked: true, state: 'closed', supportsBYOB: true }, | ||
bodyUsed: true, | ||
ok: true, | ||
redirected: false, | ||
type: 'basic', | ||
url: 'https://countries.trevorblades.com/graphql' | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
examples/output|output_envelope_envelope-error__envelope-error.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,21 @@ | ||
---------------------------------------- SHOW ---------------------------------------- | ||
{ | ||
errors: [ | ||
ContextualError: There was an error in the extension "anonymous" (use named functions to improve this error message) while running hook "encode". | ||
at runPipeline (/some/path/to/runPipeline.ts:76:18) | ||
at async Object.run (/some/path/to/main.ts:286:22) | ||
at async run (/some/path/to/client.ts:256:20) | ||
at async executeRootType (/some/path/to/client.ts:185:12) | ||
at async executeRootTypeField (/some/path/to/client.ts:216:20) | ||
at async <anonymous> (/some/path/to/output|output_envelope_envelope-error__envelope-error.ts:24:16) { | ||
context: { | ||
hookName: 'encode', | ||
source: 'extension', | ||
extensionName: 'anonymous' | ||
}, | ||
cause: Error: Something went wrong. | ||
at <anonymous> (/some/path/to/output|output_envelope_envelope-error__envelope-error.ts:20:9) | ||
at applyBody (/some/path/to/main.ts:310:28) | ||
} | ||
] | ||
} |
26 changes: 26 additions & 0 deletions
26
examples/output|output_envelope_envelope-error__envelope-error.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,26 @@ | ||
/** | ||
* This example shows how to configure output to embed errors into the envelope. | ||
*/ | ||
|
||
import { Atlas } from './$/generated-clients/atlas/__.js' | ||
import { show } from './$/helpers.js' | ||
|
||
// dprint-ignore | ||
const atlas = Atlas.create({ | ||
output: { | ||
envelope: { | ||
errors: { | ||
// ^^^^^^ | ||
execution: true, // default | ||
other: true, | ||
}, | ||
}, | ||
}, | ||
}).use(({ encode: _ }) => { | ||
throw new Error(`Something went wrong.`) | ||
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
}) | ||
|
||
const result = await atlas.query.continents({ name: true }) | ||
|
||
show(result) |
23 changes: 23 additions & 0 deletions
23
examples/output|output_envelope_envelope_error-throw__envelope-error-throw.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,23 @@ | ||
/some/path/to/runPipeline.ts:76 | ||
return new ContextualError(message, { | ||
^ | ||
|
||
|
||
ContextualError: There was an error in the extension "anonymous" (use named functions to improve this error message) while running hook "encode". | ||
at runPipeline (/some/path/to/runPipeline.ts:76:18) | ||
at async Object.run (/some/path/to/main.ts:286:22) | ||
at async run (/some/path/to/client.ts:256:20) | ||
at async executeRootType (/some/path/to/client.ts:185:12) | ||
at async executeRootTypeField (/some/path/to/client.ts:216:20) | ||
at async <anonymous> (/some/path/to/output|output_envelope_envelope_error-throw__envelope-error-throw.ts:22:1) { | ||
context: { | ||
hookName: 'encode', | ||
source: 'extension', | ||
extensionName: 'anonymous' | ||
}, | ||
cause: Error: Something went wrong. | ||
at <anonymous> (/some/path/to/output|output_envelope_envelope_error-throw__envelope-error-throw.ts:18:9) | ||
at applyBody (/some/path/to/main.ts:310:28) | ||
} | ||
|
||
Node.js vXX.XX.XX |
22 changes: 22 additions & 0 deletions
22
examples/output|output_envelope_envelope_error-throw__envelope-error-throw.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,22 @@ | ||
/** | ||
* This example shows how to configure output to throw errors even when using the envelope. | ||
*/ | ||
|
||
import { Atlas } from './$/generated-clients/atlas/__.js' | ||
|
||
// dprint-ignore | ||
const atlas = Atlas.create({ | ||
output: { | ||
envelope: { | ||
errors: { | ||
execution: false, | ||
other: false, // default | ||
} | ||
}, | ||
}, | ||
}).use(({ encode: _ }) => { | ||
throw new Error(`Something went wrong.`) | ||
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
}) | ||
|
||
await atlas.query.continents({ name: true }) |
13 changes: 13 additions & 0 deletions
13
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
---------------------------------------- SHOW ---------------------------------------- | ||
{ | ||
methodMode: 'post', | ||
headers: Headers { | ||
accept: 'application/graphql-response+json; charset=utf-8, application/json; charset=utf-8', | ||
'content-type': 'application/json', | ||
'x-sent-at-time': 'DYNAMIC_VALUE' | ||
}, | ||
signal: undefined, | ||
method: 'post', | ||
url: 'https://countries.trevorblades.com/graphql', | ||
body: '{"query":"{ languages { code } }"}' | ||
} |
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.