Skip to content

Commit

Permalink
chore(docs): improve raw coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Sep 17, 2024
1 parent 4375b22 commit d452c5e
Show file tree
Hide file tree
Showing 28 changed files with 214 additions and 161 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
headers: Headers {
accept: 'application/graphql-response+json; charset=utf-8, application/json; charset=utf-8',
'content-type': 'application/json',
'x-sent-at-time': '1726461294313'
'x-sent-at-time': '1726541102597'
},
signal: undefined,
method: 'post',
Expand Down
10 changes: 5 additions & 5 deletions examples/__outputs__/20_output/output_envelope.output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
headers: Headers {
connection: 'keep-alive',
'content-length': '119',
'x-served-by': 'cache-yul1970022-YUL',
'x-served-by': 'cache-yul1970024-YUL',
'accept-ranges': 'bytes',
date: 'Sun, 08 Sep 2024 18:13:26 GMT',
'content-type': 'application/graphql-response+json; charset=utf-8',
Expand All @@ -32,13 +32,13 @@
'alt-svc': 'h3=":443"; ma=86400',
'access-control-allow-origin': '*',
'x-powered-by': 'Stellate',
age: '642089',
age: '721898',
'cache-control': 'public, s-maxage=2628000, stale-while-revalidate=2628000',
'x-cache': 'HIT',
'x-cache-hits': '80',
'x-cache-hits': '84',
'gcdn-cache': 'HIT',
'stellate-rate-limit-budget-remaining': '47',
'stellate-rate-limit-rules': '"IP limit";type="RequestCount";budget=50;limited=?0;remaining=47;refill=60',
'stellate-rate-limit-budget-remaining': '44',
'stellate-rate-limit-rules': '"IP limit";type="RequestCount";budget=50;limited=?0;remaining=44;refill=59',
'stellate-rate-limit-decision': 'pass',
'stellate-rate-limit-budget-required': '5',
'content-encoding': 'br'
Expand Down
File renamed without changes.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '33c2903599214054eb34ee8382ee63e1',
parentId: 'a9cd435480d53274',
traceId: '9f4dcc1213a3f3d4605da3d9c3340361',
parentId: 'f0c18d7e669cfd3d',
traceState: undefined,
name: 'encode',
id: 'ae33c18f5cc9cae0',
id: 'e06d4e860f48bc58',
kind: 0,
timestamp: 1726461294589000,
duration: 539.583,
timestamp: 1726541103051000,
duration: 552.125,
attributes: {},
status: { code: 0 },
events: [],
Expand All @@ -33,14 +33,14 @@
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '33c2903599214054eb34ee8382ee63e1',
parentId: 'a9cd435480d53274',
traceId: '9f4dcc1213a3f3d4605da3d9c3340361',
parentId: 'f0c18d7e669cfd3d',
traceState: undefined,
name: 'pack',
id: '95b40ccefe000e6e',
id: 'a29e1e9baaa80c0e',
kind: 0,
timestamp: 1726461294591000,
duration: 1186.792,
timestamp: 1726541103053000,
duration: 1086.75,
attributes: {},
status: { code: 0 },
events: [],
Expand All @@ -57,14 +57,14 @@
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '33c2903599214054eb34ee8382ee63e1',
parentId: 'a9cd435480d53274',
traceId: '9f4dcc1213a3f3d4605da3d9c3340361',
parentId: 'f0c18d7e669cfd3d',
traceState: undefined,
name: 'exchange',
id: '986a75e706d54ec1',
id: 'f2a21df585a2fdbb',
kind: 0,
timestamp: 1726461294593000,
duration: 147109.584,
timestamp: 1726541103055000,
duration: 177279.959,
attributes: {},
status: { code: 0 },
events: [],
Expand All @@ -81,14 +81,14 @@
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '33c2903599214054eb34ee8382ee63e1',
parentId: 'a9cd435480d53274',
traceId: '9f4dcc1213a3f3d4605da3d9c3340361',
parentId: 'f0c18d7e669cfd3d',
traceState: undefined,
name: 'unpack',
id: '2bd1476a05bb0a51',
id: '2088b4af9a15807e',
kind: 0,
timestamp: 1726461294741000,
duration: 2265.625,
timestamp: 1726541103233000,
duration: 2944,
attributes: {},
status: { code: 0 },
events: [],
Expand All @@ -105,14 +105,14 @@
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '33c2903599214054eb34ee8382ee63e1',
parentId: 'a9cd435480d53274',
traceId: '9f4dcc1213a3f3d4605da3d9c3340361',
parentId: 'f0c18d7e669cfd3d',
traceState: undefined,
name: 'decode',
id: '40a75edd2f4f08d4',
id: '11a1c3568453721f',
kind: 0,
timestamp: 1726461294743000,
duration: 124.542,
timestamp: 1726541103236000,
duration: 127.375,
attributes: {},
status: { code: 0 },
events: [],
Expand All @@ -129,14 +129,14 @@
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '33c2903599214054eb34ee8382ee63e1',
traceId: '9f4dcc1213a3f3d4605da3d9c3340361',
parentId: undefined,
traceState: undefined,
name: 'request',
id: 'a9cd435480d53274',
id: 'f0c18d7e669cfd3d',
kind: 0,
timestamp: 1726461294589000,
duration: 154733.292,
timestamp: 1726541103050000,
duration: 186111.542,
attributes: {},
status: { code: 0 },
events: [],
Expand Down
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(`raw_rawDocumentNode__raw-document-node`, async () => {
const exampleResult = await runExample(`./examples/30_raw/raw_rawDocumentNode__raw-document-node.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__/30_raw/raw_rawDocumentNode__raw-document-node.output.txt`,
)
})
19 changes: 19 additions & 0 deletions tests/examples/30_raw/raw_rawDocumentNode__raw.test.ts
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(`raw_rawDocumentNode__raw`, async () => {
const exampleResult = await runExample(`./examples/30_raw/raw_rawDocumentNode__raw.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__/30_raw/raw_rawDocumentNode__raw.output.txt`,
)
})
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(`raw_rawDocumentNode_rawTyped__raw-document-node-typed`, async () => {
const exampleResult = await runExample(`./examples/30_raw/raw_rawDocumentNode_rawTyped__raw-document-node-typed.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__/30_raw/raw_rawDocumentNode_rawTyped__raw-document-node-typed.output.txt`,
)
})
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(`raw_rawDocumentNode_rawTyped__raw-typed`, async () => {
const exampleResult = await runExample(`./examples/30_raw/raw_rawDocumentNode_rawTyped__raw-typed.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__/30_raw/raw_rawDocumentNode_rawTyped__raw-typed.output.txt`,
)
})
19 changes: 19 additions & 0 deletions tests/examples/40_other/anyware.test.ts
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(`anyware`, async () => {
const exampleResult = await runExample(`./examples/40_other/anyware.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__/40_other/anyware.output.txt`,
)
})
1 change: 1 addition & 0 deletions website/content/_snippets/example-links/anyware.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p class="ExampleLinks">Examples <span class="ExampleLinksTitleSeparator">-></span> <a href="../../examples/other/anyware">Anyware</a></p>
2 changes: 1 addition & 1 deletion website/content/_snippets/example-links/raw.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p class="ExampleLinks">Examples <span class="ExampleLinksTitleSeparator">-></span> <a href="../../examples/transport-http/headers">Headers</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/transport-http/raw">Raw</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/raw/raw">Raw</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/raw/raw-string">Raw String</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/raw/raw-string-typed">Raw String Typed</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/raw/raw-typed">Raw Typed</a></p>
<p class="ExampleLinks">Examples <span class="ExampleLinksTitleSeparator">-></span> <a href="../../examples/transport-http/headers">Headers</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/transport-http/raw">Raw</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/raw/raw-document-node">Raw Document Node</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/raw/raw-document-node-typed">Raw Document Node Typed</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/raw/raw-string">Raw String</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/raw/raw-string-typed">Raw String Typed</a></p>
1 change: 1 addition & 0 deletions website/content/_snippets/example-links/rawDocumentNode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p class="ExampleLinks">Examples <span class="ExampleLinksTitleSeparator">-></span> <a href="../../examples/raw/raw-document-node">Raw Document Node</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/raw/raw-document-node-typed">Raw Document Node Typed</a></p>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p class="ExampleLinks">Examples <span class="ExampleLinksTitleSeparator">-></span> <a href="../../examples/raw/raw-document-node-typed">Raw Document Node Typed</a></p>
2 changes: 1 addition & 1 deletion website/content/_snippets/example-links/rawTyped.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p class="ExampleLinks">Examples <span class="ExampleLinksTitleSeparator">-></span> <a href="../../examples/raw/raw-string-typed">Raw String Typed</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/raw/raw-typed">Raw Typed</a></p>
<p class="ExampleLinks">Examples <span class="ExampleLinksTitleSeparator">-></span> <a href="../../examples/raw/raw-document-node-typed">Raw Document Node Typed</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/raw/raw-string-typed">Raw String Typed</a></p>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p class="ExampleLinks">Examples <span class="ExampleLinksTitleSeparator">-></span> <a href="../../examples/raw/raw-document-node">Raw Document Node</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/raw/raw-document-node-typed">Raw Document Node Typed</a></p>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p class="ExampleLinks">Examples <span class="ExampleLinksTitleSeparator">-></span> <a href="../../examples/raw/raw-document-node-typed">Raw Document Node Typed</a></p>
2 changes: 1 addition & 1 deletion website/content/_snippets/example-links/raw_rawTyped.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p class="ExampleLinks">Examples <span class="ExampleLinksTitleSeparator">-></span> <a href="../../examples/raw/raw-string-typed">Raw String Typed</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/raw/raw-typed">Raw Typed</a></p>
<p class="ExampleLinks">Examples <span class="ExampleLinksTitleSeparator">-></span> <a href="../../examples/raw/raw-document-node-typed">Raw Document Node Typed</a> <span class="ExampleLinksSeparator"></span> <a href="../../examples/raw/raw-string-typed">Raw String Typed</a></p>
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ await graffle.rawString({ document: `{ languages { code } }` })
headers: Headers {
accept: 'application/graphql-response+json; charset=utf-8, application/json; charset=utf-8',
'content-type': 'application/json',
'x-sent-at-time': '1726461294313'
'x-sent-at-time': '1726541102597'
},
signal: undefined,
method: 'post',
Expand Down
10 changes: 5 additions & 5 deletions website/content/examples/20_output/envelope.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ console.log(result)
headers: Headers {
connection: 'keep-alive',
'content-length': '119',
'x-served-by': 'cache-yul1970022-YUL',
'x-served-by': 'cache-yul1970024-YUL',
'accept-ranges': 'bytes',
date: 'Sun, 08 Sep 2024 18:13:26 GMT',
'content-type': 'application/graphql-response+json; charset=utf-8',
Expand All @@ -59,13 +59,13 @@ console.log(result)
'alt-svc': 'h3=":443"; ma=86400',
'access-control-allow-origin': '*',
'x-powered-by': 'Stellate',
age: '642089',
age: '721898',
'cache-control': 'public, s-maxage=2628000, stale-while-revalidate=2628000',
'x-cache': 'HIT',
'x-cache-hits': '80',
'x-cache-hits': '84',
'gcdn-cache': 'HIT',
'stellate-rate-limit-budget-remaining': '47',
'stellate-rate-limit-rules': '"IP limit";type="RequestCount";budget=50;limited=?0;remaining=47;refill=60',
'stellate-rate-limit-budget-remaining': '44',
'stellate-rate-limit-rules': '"IP limit";type="RequestCount";budget=50;limited=?0;remaining=44;refill=59',
'stellate-rate-limit-decision': 'pass',
'stellate-rate-limit-budget-required': '5',
'content-encoding': 'br'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
aside: false
---

# Raw Typed
# Raw Document Node Typed

This example shows how to send a request using a Document instance for the GraphQL document while also being typesafe in regards to the passed variables and return type.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
aside: false
---

# Raw
# Raw Document Node

This example shows how to send a request using a Document instance for the GraphQL document.

Expand Down
29 changes: 29 additions & 0 deletions website/content/examples/40_other/anyware.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
aside: false
---

# Anyware

<!-- dprint-ignore-start -->
```ts twoslash
import { Graffle } from 'graffle'

Graffle
.create({ schema: `https://countries.trevorblades.com/graphql` })
.anyware(async ({ encode }) => {
if (encode.input.interface === 'typed') {
// Do something here.
}

if (encode.input.transport === 'memory') {
// Do something here.
}

// etc.

return encode()
})
```
<!-- dprint-ignore-end -->

#### Outputs
Loading

0 comments on commit d452c5e

Please sign in to comment.