Skip to content

Commit

Permalink
chore(docs): append output to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Aug 24, 2024
1 parent e9ab5cb commit 2a4dc4c
Show file tree
Hide file tree
Showing 11 changed files with 287 additions and 57 deletions.
35 changes: 18 additions & 17 deletions website/.vitepress/configExamples.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
import { DefaultTheme } from 'vitepress'

export const sidebarExamples: DefaultTheme.SidebarItem[] = [
import { DefaultTheme } from 'vitepress'

export const sidebarExamples:DefaultTheme.SidebarItem[] = [
{
'text': 'Arguments',
'link': '/examples/arguments',
"text": "Arguments",
"link": "/examples/arguments"
},
{
'text': 'Config Fetch',
'link': '/examples/config-fetch',
"text": "Config Fetch",
"link": "/examples/config-fetch"
},
{
'text': 'Config Http Headers',
'link': '/examples/config-http-headers',
"text": "Config Http Headers",
"link": "/examples/config-http-headers"
},
{
'text': 'Raw Typed',
'link': '/examples/raw-typed',
"text": "Raw Typed",
"link": "/examples/raw-typed"
},
{
'text': 'Raw',
'link': '/examples/raw',
"text": "Raw",
"link": "/examples/raw"
},
{
'text': 'RawString Typed',
'link': '/examples/rawString-typed',
"text": "RawString Typed",
"link": "/examples/rawString-typed"
},
{
'text': 'RawString',
'link': '/examples/rawString',
},
"text": "RawString",
"link": "/examples/rawString"
}
]
12 changes: 12 additions & 0 deletions website/content/examples/arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
aside: false
---

# Arguments

```ts twoslash
import './graffle/Global.js'
// ---cut---
Expand All @@ -18,3 +20,13 @@ const countries = await socialStudies.query.countries({
console.log(countries)
// ^?
```

#### Output

```json
[
{ name: 'Canada', continent: { name: 'North America' } },
{ name: 'Germany', continent: { name: 'Europe' } },
{ name: 'Japan', continent: { name: 'Asia' } }
]
```
14 changes: 9 additions & 5 deletions website/content/examples/config-fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
aside: false
---

# Config Fetch

```ts twoslash
import './graffle/Global.js'
// ---cut---
Expand All @@ -14,11 +16,7 @@ const socialStudies = SocialStudies.create()
return await exchange({
using: {
fetch: async () => {
return new Response(
JSON.stringify({
data: { countries: [{ name: `Canada Mocked!` }] },
}),
)
return new Response(JSON.stringify({ data: { countries: [{ name: `Canada Mocked!` }] } }))
},
},
})
Expand All @@ -34,3 +32,9 @@ const countries = await socialStudies.query.countries({
console.log(countries)
// ^?
```

#### Output

```json
[ { name: 'Canada Mocked!' } ]
```
16 changes: 16 additions & 0 deletions website/content/examples/config-http-headers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
aside: false
---

# Config Http Headers

```ts twoslash
import './graffle/Global.js'
// ---cut---
Expand All @@ -18,3 +20,17 @@ const continents = await socialStudies.query.continents({ name: true })
console.log(continents)
// ^?
```

#### Output

```json
[
{ name: 'Africa' },
{ name: 'Antarctica' },
{ name: 'Asia' },
{ name: 'Europe' },
{ name: 'North America' },
{ name: 'Oceania' },
{ name: 'South America' }
]
```
32 changes: 20 additions & 12 deletions website/content/examples/raw-typed.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
aside: false
---

# Raw Typed

```ts twoslash
import type { TypedQueryDocumentNode } from 'graphql'
import { gql, Graffle } from 'graphql-request/graffle/main'
Expand All @@ -19,10 +21,7 @@ const graffle = Graffle.create({
*/

{
const document = gql<
{ countries: { name: string; continent: { name: string } }[] },
{ filter: string[] }
>`
const document = gql<{ countries: { name: string; continent: { name: string } }[] }, { filter: string[] }>`
query countries ($filter: [String!]) {
countries (filter: { name: { in: $filter } }) {
name
Expand All @@ -33,10 +32,7 @@ const graffle = Graffle.create({
}
`

const result = await graffle.raw({
document,
variables: { filter: [`Canada`, `Germany`, `Japan`] },
})
const result = await graffle.raw({ document, variables: { filter: [`Canada`, `Germany`, `Japan`] } })

console.log(result.data?.countries)
}
Expand Down Expand Up @@ -66,11 +62,23 @@ const graffle = Graffle.create({
}
`

const result = await graffle.raw({
document,
variables: { filter: [`Canada`, `Germany`, `Japan`] },
})
const result = await graffle.raw({ document, variables: { filter: [`Canada`, `Germany`, `Japan`] } })

console.log(result.data?.countries)
}
```

#### Output

```json
[
{ name: 'Canada', continent: { name: 'North America' } },
{ name: 'Germany', continent: { name: 'Europe' } },
{ name: 'Japan', continent: { name: 'Asia' } }
]
[
{ name: 'Canada', continent: { name: 'North America' } },
{ name: 'Germany', continent: { name: 'Europe' } },
{ name: 'Japan', continent: { name: 'Asia' } }
]
```
14 changes: 14 additions & 0 deletions website/content/examples/raw.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
aside: false
---

# Raw

```ts twoslash
import { gql, Graffle } from 'graphql-request/graffle/main'

Expand All @@ -26,3 +28,15 @@ const result = await graffle.raw({
console.log(result.data)
// ^?
```

#### Output

```json
{
countries: [
{ name: 'Canada', continent: { name: 'North America' } },
{ name: 'Germany', continent: { name: 'Europe' } },
{ name: 'Japan', continent: { name: 'Asia' } }
]
}
```
12 changes: 12 additions & 0 deletions website/content/examples/rawString-typed.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
aside: false
---

# RawString Typed

```ts twoslash
import { Graffle } from 'graphql-request/graffle/main'
// todo from 'graphql-request/graffle/utils'
Expand Down Expand Up @@ -41,3 +43,13 @@ const result = await graffle.rawString({
console.log(result.data?.countries)
// ^?
```

#### Output

```json
[
{ name: 'Canada', continent: { name: 'North America' } },
{ name: 'Germany', continent: { name: 'Europe' } },
{ name: 'Japan', continent: { name: 'Asia' } }
]
```
112 changes: 112 additions & 0 deletions website/content/examples/rawString.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
aside: false
---

# RawString

```ts twoslash
import { Graffle } from 'graphql-request/graffle/main'

Expand All @@ -24,3 +26,113 @@ const result = await graffle.rawString({
console.log(result.data)
// ^?
```

#### Output

```json
{
countries: [
{ name: 'Andorra' },
{ name: 'United Arab Emirates' },
{ name: 'Afghanistan' },
{ name: 'Antigua and Barbuda' },
{ name: 'Anguilla' },
{ name: 'Albania' },
{ name: 'Armenia' },
{ name: 'Angola' },
{ name: 'Antarctica' },
{ name: 'Argentina' },
{ name: 'American Samoa' },
{ name: 'Austria' },
{ name: 'Australia' },
{ name: 'Aruba' },
{ name: 'Åland' },
{ name: 'Azerbaijan' },
{ name: 'Bosnia and Herzegovina' },
{ name: 'Barbados' },
{ name: 'Bangladesh' },
{ name: 'Belgium' },
{ name: 'Burkina Faso' },
{ name: 'Bulgaria' },
{ name: 'Bahrain' },
{ name: 'Burundi' },
{ name: 'Benin' },
{ name: 'Saint Barthélemy' },
{ name: 'Bermuda' },
{ name: 'Brunei' },
{ name: 'Bolivia' },
{ name: 'Bonaire' },
{ name: 'Brazil' },
{ name: 'Bahamas' },
{ name: 'Bhutan' },
{ name: 'Bouvet Island' },
{ name: 'Botswana' },
{ name: 'Belarus' },
{ name: 'Belize' },
{ name: 'Canada' },
{ name: 'Cocos [Keeling] Islands' },
{ name: 'Democratic Republic of the Congo' },
{ name: 'Central African Republic' },
{ name: 'Republic of the Congo' },
{ name: 'Switzerland' },
{ name: 'Ivory Coast' },
{ name: 'Cook Islands' },
{ name: 'Chile' },
{ name: 'Cameroon' },
{ name: 'China' },
{ name: 'Colombia' },
{ name: 'Costa Rica' },
{ name: 'Cuba' },
{ name: 'Cape Verde' },
{ name: 'Curacao' },
{ name: 'Christmas Island' },
{ name: 'Cyprus' },
{ name: 'Czech Republic' },
{ name: 'Germany' },
{ name: 'Djibouti' },
{ name: 'Denmark' },
{ name: 'Dominica' },
{ name: 'Dominican Republic' },
{ name: 'Algeria' },
{ name: 'Ecuador' },
{ name: 'Estonia' },
{ name: 'Egypt' },
{ name: 'Western Sahara' },
{ name: 'Eritrea' },
{ name: 'Spain' },
{ name: 'Ethiopia' },
{ name: 'Finland' },
{ name: 'Fiji' },
{ name: 'Falkland Islands' },
{ name: 'Micronesia' },
{ name: 'Faroe Islands' },
{ name: 'France' },
{ name: 'Gabon' },
{ name: 'United Kingdom' },
{ name: 'Grenada' },
{ name: 'Georgia' },
{ name: 'French Guiana' },
{ name: 'Guernsey' },
{ name: 'Ghana' },
{ name: 'Gibraltar' },
{ name: 'Greenland' },
{ name: 'Gambia' },
{ name: 'Guinea' },
{ name: 'Guadeloupe' },
{ name: 'Equatorial Guinea' },
{ name: 'Greece' },
{ name: 'South Georgia and the South Sandwich Islands' },
{ name: 'Guatemala' },
{ name: 'Guam' },
{ name: 'Guinea-Bissau' },
{ name: 'Guyana' },
{ name: 'Hong Kong' },
{ name: 'Heard Island and McDonald Islands' },
{ name: 'Honduras' },
{ name: 'Croatia' },
{ name: 'Haiti' },
{ name: 'Hungary' },
... 150 more items
]
}
```
1 change: 1 addition & 0 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"dependencies": {
"@shikijs/twoslash": "^1.13.0",
"@shikijs/vitepress-twoslash": "^1.13.0",
"es-toolkit": "^1.16.0",
"floating-vue": "^5.2.2",
"globby": "^14.0.2",
"graphql-request": "file:..",
Expand Down
Loading

0 comments on commit 2a4dc4c

Please sign in to comment.