Skip to content

Commit

Permalink
chore(docs): put all examples into groups
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Sep 10, 2024
1 parent 4545eb4 commit 6c84840
Show file tree
Hide file tree
Showing 33 changed files with 68 additions and 56 deletions.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions examples/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-yul1970039-YUL',
'x-served-by': 'cache-yul1970035-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: '109533',
age: '109762',
'cache-control': 'public, s-maxage=2628000, stale-while-revalidate=2628000',
'x-cache': 'HIT',
'x-cache-hits': '17',
'x-cache-hits': '9',
'gcdn-cache': 'HIT',
'stellate-rate-limit-budget-remaining': '45',
'stellate-rate-limit-rules': '"IP limit";type="RequestCount";budget=50;limited=?0;remaining=45;refill=60',
'stellate-rate-limit-budget-remaining': '38',
'stellate-rate-limit-rules': '"IP limit";type="RequestCount";budget=50;limited=?0;remaining=38;refill=21',
'stellate-rate-limit-decision': 'pass',
'stellate-rate-limit-budget-required': '5',
'content-encoding': 'br'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
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': '1725928738805'
'x-sent-at-time': '1725928966760'
},
signal: undefined,
method: 'post',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { execaCommand } from 'execa'
import stripAnsi from 'strip-ansi'
import { expect, test } from 'vitest'

test(`transport-memory`, async () => {
const result = await execaCommand(`pnpm tsx ./examples/transport-memory.ts`)
test(`other|transport-memory`, async () => {
const result = await execaCommand(`pnpm tsx ./examples/other|transport-memory.ts`)
expect(result.exitCode).toBe(0)
// Examples should output their data results.
const exampleResult = 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-memory.output.txt`)
await expect(exampleResult).toMatchFileSnapshot(`../.././examples/other|transport-memory.output.txt`)
})
6 changes: 3 additions & 3 deletions tests/examples/raw.test.ts → tests/examples/raw|raw.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { execaCommand } from 'execa'
import stripAnsi from 'strip-ansi'
import { expect, test } from 'vitest'

test(`raw`, async () => {
const result = await execaCommand(`pnpm tsx ./examples/raw.ts`)
test(`raw|raw`, async () => {
const result = await execaCommand(`pnpm tsx ./examples/raw|raw.ts`)
expect(result.exitCode).toBe(0)
// Examples should output their data results.
const exampleResult = 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/raw.output.txt`)
await expect(exampleResult).toMatchFileSnapshot(`../.././examples/raw|raw.output.txt`)
})
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { execaCommand } from 'execa'
import stripAnsi from 'strip-ansi'
import { expect, test } from 'vitest'

test(`raw_rawTyped__raw-typed`, async () => {
const result = await execaCommand(`pnpm tsx ./examples/raw_rawTyped__raw-typed.ts`)
test(`raw|raw_rawString__rawString`, async () => {
const result = await execaCommand(`pnpm tsx ./examples/raw|raw_rawString__rawString.ts`)
expect(result.exitCode).toBe(0)
// Examples should output their data results.
const exampleResult = 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/raw_rawTyped__raw-typed.output.txt`)
await expect(exampleResult).toMatchFileSnapshot(`../.././examples/raw|raw_rawString__rawString.output.txt`)
})
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import { execaCommand } from 'execa'
import stripAnsi from 'strip-ansi'
import { expect, test } from 'vitest'

test(`raw_rawString_rawTyped__rawString-typed`, async () => {
const result = await execaCommand(`pnpm tsx ./examples/raw_rawString_rawTyped__rawString-typed.ts`)
test(`raw|raw_rawString_rawTyped__rawString-typed`, async () => {
const result = await execaCommand(`pnpm tsx ./examples/raw|raw_rawString_rawTyped__rawString-typed.ts`)
expect(result.exitCode).toBe(0)
// Examples should output their data results.
const exampleResult = 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/raw_rawString_rawTyped__rawString-typed.output.txt`)
await expect(exampleResult).toMatchFileSnapshot(
`../.././examples/raw|raw_rawString_rawTyped__rawString-typed.output.txt`,
)
})
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { execaCommand } from 'execa'
import stripAnsi from 'strip-ansi'
import { expect, test } from 'vitest'

test(`raw_rawString__rawString`, async () => {
const result = await execaCommand(`pnpm tsx ./examples/raw_rawString__rawString.ts`)
test(`raw|raw_rawTyped__raw-typed`, async () => {
const result = await execaCommand(`pnpm tsx ./examples/raw|raw_rawTyped__raw-typed.ts`)
expect(result.exitCode).toBe(0)
// Examples should output their data results.
const exampleResult = 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/raw_rawString__rawString.output.txt`)
await expect(exampleResult).toMatchFileSnapshot(`../.././examples/raw|raw_rawTyped__raw-typed.output.txt`)
})
50 changes: 30 additions & 20 deletions website/.vitepress/configExamples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,6 @@
import { DefaultTheme } from 'vitepress'

export const sidebarExamples:DefaultTheme.SidebarItem[] = [
{
"text": "Transport Memory",
"link": "/examples/transport-memory"
},
{
"text": "Raw Typed",
"link": "/examples/raw-typed"
},
{
"text": "Raw String Typed",
"link": "/examples/raw-string-typed"
},
{
"text": "Raw String",
"link": "/examples/raw-string"
},
{
"text": "Raw",
"link": "/examples/raw"
},
{
"text": "Generated",
"items": [
Expand All @@ -31,6 +11,15 @@
}
]
},
{
"text": "Other",
"items": [
{
"text": "Transport Memory",
"link": "/examples/other-transport-memory"
}
]
},
{
"text": "Output",
"items": [
Expand All @@ -44,6 +33,27 @@
}
]
},
{
"text": "Raw",
"items": [
{
"text": "",
"link": "/examples/raw-"
},
{
"text": "Raw String",
"link": "/examples/raw-raw-string"
},
{
"text": "Raw String Typed",
"link": "/examples/raw-raw-string-typed"
},
{
"text": "Raw Typed",
"link": "/examples/raw-raw-typed"
}
]
},
{
"text": "Transport Http",
"items": [
Expand Down
10 changes: 5 additions & 5 deletions website/content/examples/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-yul1970039-YUL',
'x-served-by': 'cache-yul1970035-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: '109533',
age: '109762',
'cache-control': 'public, s-maxage=2628000, stale-while-revalidate=2628000',
'x-cache': 'HIT',
'x-cache-hits': '17',
'x-cache-hits': '9',
'gcdn-cache': 'HIT',
'stellate-rate-limit-budget-remaining': '45',
'stellate-rate-limit-rules': '"IP limit";type="RequestCount";budget=50;limited=?0;remaining=45;refill=60',
'stellate-rate-limit-budget-remaining': '38',
'stellate-rate-limit-rules': '"IP limit";type="RequestCount";budget=50;limited=?0;remaining=38;refill=21',
'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
#

<!-- dprint-ignore-start -->
```ts twoslash
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion website/content/examples/transport-http-dynamic-headers.md
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': '1725928738805'
'x-sent-at-time': '1725928966760'
},
signal: undefined,
method: 'post',
Expand Down
2 changes: 1 addition & 1 deletion website/content/guides/_example_links/raw.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
###### Examples -> [Raw](../../examples/raw.md) / [Raw String](../../examples/raw-string.md) / [Raw String Typed](../../examples/raw-string-typed.md) / [Raw Typed](../../examples/raw-typed.md) / [Headers](../../examples/transport-http-headers.md) / [Raw](../../examples/transport-http-raw.md)
###### Examples -> [](../../examples/raw-.md) / [Raw String](../../examples/raw-raw-string.md) / [Raw String Typed](../../examples/raw-raw-string-typed.md) / [Raw Typed](../../examples/raw-raw-typed.md) / [Headers](../../examples/transport-http-headers.md) / [Raw](../../examples/transport-http-raw.md)
2 changes: 1 addition & 1 deletion website/content/guides/_example_links/rawString.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
###### Examples -> [Raw String](../../examples/raw-string.md) / [Raw String Typed](../../examples/raw-string-typed.md)
###### Examples -> [Raw String](../../examples/raw-raw-string.md) / [Raw String Typed](../../examples/raw-raw-string-typed.md)
Original file line number Diff line number Diff line change
@@ -1 +1 @@
###### Examples -> [Raw String Typed](../../examples/raw-string-typed.md)
###### Examples -> [Raw String Typed](../../examples/raw-raw-string-typed.md)
2 changes: 1 addition & 1 deletion website/content/guides/_example_links/rawTyped.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
###### Examples -> [Raw String Typed](../../examples/raw-string-typed.md) / [Raw Typed](../../examples/raw-typed.md)
###### Examples -> [Raw String Typed](../../examples/raw-raw-string-typed.md) / [Raw Typed](../../examples/raw-raw-typed.md)
2 changes: 1 addition & 1 deletion website/content/guides/_example_links/raw_rawString.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
###### Examples -> [Raw String](../../examples/raw-string.md) / [Raw String Typed](../../examples/raw-string-typed.md)
###### Examples -> [Raw String](../../examples/raw-raw-string.md) / [Raw String Typed](../../examples/raw-raw-string-typed.md)
Original file line number Diff line number Diff line change
@@ -1 +1 @@
###### Examples -> [Raw String Typed](../../examples/raw-string-typed.md)
###### Examples -> [Raw String Typed](../../examples/raw-raw-string-typed.md)
2 changes: 1 addition & 1 deletion website/content/guides/_example_links/raw_rawTyped.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
###### Examples -> [Raw String Typed](../../examples/raw-string-typed.md) / [Raw Typed](../../examples/raw-typed.md)
###### Examples -> [Raw String Typed](../../examples/raw-raw-string-typed.md) / [Raw Typed](../../examples/raw-raw-typed.md)
2 changes: 1 addition & 1 deletion website/content/guides/_example_links/transport-memory.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
###### Examples -> [Transport Memory](../../examples/transport-memory.md)
###### Examples -> [Transport Memory](../../examples/other-transport-memory.md)

0 comments on commit 6c84840

Please sign in to comment.