Skip to content

Commit

Permalink
chore: all schemas to tests dir (#1141)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt authored Sep 27, 2024
1 parent fb3ffc3 commit 9acf22c
Show file tree
Hide file tree
Showing 187 changed files with 452 additions and 1,361 deletions.
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default tsEslint.config({
'vite.config.ts',
'vitest*.config.ts',
'**/generated/**/*',
'tests/_/schemas/*/graffle/**/*',
'**/$/**/*',
'legacy/**/*',
'build/**/*',
Expand Down
1 change: 0 additions & 1 deletion examples/$/generated-clients/pokemon/modules/Scalar.ts

This file was deleted.

14 changes: 0 additions & 14 deletions examples/$/schemas/pokemon/generateSdl.ts

This file was deleted.

2 changes: 1 addition & 1 deletion examples/10_transport-http/transport-http_method-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* to be sent over HTTP GET method. Note write-kind operations (mutation) are still sent over HTTP POST method.
*/

import { Pokemon } from '../$/generated-clients/pokemon/__.js'
import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { show } from '../$/helpers.js'

const graffle = Pokemon
Expand Down
2 changes: 1 addition & 1 deletion examples/20_output/output_default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This example shows the default output behavior.
*/

import { Pokemon } from '../$/generated-clients/pokemon/__.js'
import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { show } from '../$/helpers.js'

const pokemon = Pokemon.create()
Expand Down
2 changes: 1 addition & 1 deletion examples/20_output/output_envelope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This example shows how to configure output to use the envelope.
*/

import { Pokemon } from '../$/generated-clients/pokemon/__.js'
import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { show } from '../$/helpers.js'

const pokemon = Pokemon.create({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This example shows how to configure output to embed errors into the envelope.
*/

import { Pokemon } from '../$/generated-clients/pokemon/__.js'
import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { show } from '../$/helpers.js'

// dprint-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This example shows how to configure output to throw errors even when using the envelope.
*/

import { Pokemon } from '../$/generated-clients/pokemon/__.js'
import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js'

// dprint-ignore
const pokemon = Pokemon
Expand Down
2 changes: 1 addition & 1 deletion examples/20_output/output_return-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This example shows how to configure output to have errors returned instead of e.g. thrown.
*/

import { Pokemon } from '../$/generated-clients/pokemon/__.js'
import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { show } from '../$/helpers.js'

// dprint-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This example shows how to configure output to have only certain kinds of errors returned while others thrown.
*/

import { Pokemon } from '../$/generated-clients/pokemon/__.js'
import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { show } from '../$/show.js'

const pokemon = Pokemon
Expand Down
2 changes: 1 addition & 1 deletion examples/55_generated/generated_alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This example shows how to write GraphQL aliases in the TypeScript interface.
*/

import { Pokemon } from '../$/generated-clients/pokemon/__.js'
import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { showJson } from '../$/helpers.js'

const pokemon = Pokemon.create()
Expand Down
2 changes: 1 addition & 1 deletion examples/55_generated/generated_arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This example shows how to write field arguments in TypeScript interface.
*/

import { Pokemon } from '../$/generated-clients/pokemon/__.js'
import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { showJson } from '../$/helpers.js'

const atlas = Pokemon.create()
Expand Down
2 changes: 1 addition & 1 deletion examples/55_generated/generated_batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This example shows how to write batches of GraphQL root fields (aka. entrypoints) in the TypeScript interface.
*/

import { Pokemon } from '../$/generated-clients/pokemon/__.js'
import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { showJson } from '../$/helpers.js'

const pokemon = Pokemon.create()
Expand Down
2 changes: 1 addition & 1 deletion examples/55_generated/generated_directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

// import { parse, print } from 'graphql'
import { Pokemon } from '../$/generated-clients/pokemon/__.js'
import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { showJson } from '../$/helpers.js'

const pokemon = Pokemon.create()
Expand Down
2 changes: 1 addition & 1 deletion examples/55_generated/generated_document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This example shows how to write whole GraphQL documents in the TypeScript interface.
*/

import { Pokemon } from '../$/generated-clients/pokemon/__.js'
import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { showJson } from '../$/helpers.js'

const pokemon = Pokemon.create()
Expand Down
2 changes: 1 addition & 1 deletion examples/55_generated/generated_interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This example shows how to work with interface types.
*/

import { Pokemon } from '../$/generated-clients/pokemon/__.js'
import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { show } from '../$/helpers.js'

const pokemon = Pokemon.create()
Expand Down
2 changes: 1 addition & 1 deletion examples/55_generated/generated_root-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This example shows how to use dedicated root field methods to easily operate on one GraphQL root field at at time. If you need to work with multiple root fields, check out the `batch` example.
*/

import { Pokemon } from '../$/generated-clients/pokemon/__.js'
import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { showJson } from '../$/helpers.js'

const pokemon = Pokemon.create()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base'
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node'
import { Opentelemetry } from '../../src/entrypoints/extensions.js'
import { Pokemon } from '../$/generated-clients/pokemon/__.js'
import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { interceptAndShowOutput, show } from '../$/helpers.js'

interceptAndShowOutput()
Expand Down
2 changes: 1 addition & 1 deletion examples/60_extension/extension_throws__throws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import { Throws } from '../../src/entrypoints/extensions.js'
import { Pokemon } from '../$/generated-clients/pokemon/__.js'
import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { interceptAndShowUncaughtErrors, show } from '../$/show.js'

interceptAndShowUncaughtErrors()
Expand Down
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': '1727408110664'
'x-sent-at-time': '1727447640287'
},
signal: undefined,
method: 'post',
Expand Down
2 changes: 1 addition & 1 deletion examples/__outputs__/20_output/output_envelope.output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
headers: Headers {
'content-type': 'application/graphql-response+json; charset=utf-8',
'content-length': '104',
date: 'Fri, 27 Sep 2024 03:35:11 GMT',
date: 'Fri, 27 Sep 2024 14:34:00 GMT',
connection: 'keep-alive',
'keep-alive': 'timeout=5'
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '955a83e23fd481c11e99476809785250',
parentId: '2e4746bd4a491302',
traceId: '9039f59347f6f75a8d39d0b53a9995e0',
parentId: '235586747a904981',
traceState: undefined,
name: 'encode',
id: '288e327eea7ce997',
id: 'b198600c41de0595',
kind: 0,
timestamp: 1727408111781000,
duration: 539.958,
timestamp: 1727447640559000,
duration: 638.625,
attributes: {},
status: { code: 0 },
events: [],
Expand All @@ -33,14 +33,14 @@
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '955a83e23fd481c11e99476809785250',
parentId: '2e4746bd4a491302',
traceId: '9039f59347f6f75a8d39d0b53a9995e0',
parentId: '235586747a904981',
traceState: undefined,
name: 'pack',
id: 'b1df38e68926a3a5',
id: '83bc7ce70496db8d',
kind: 0,
timestamp: 1727408111783000,
duration: 10846,
timestamp: 1727447640562000,
duration: 11628.625,
attributes: {},
status: { code: 0 },
events: [],
Expand All @@ -57,14 +57,14 @@
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '955a83e23fd481c11e99476809785250',
parentId: '2e4746bd4a491302',
traceId: '9039f59347f6f75a8d39d0b53a9995e0',
parentId: '235586747a904981',
traceState: undefined,
name: 'exchange',
id: '85f8c97a5cdf40a0',
id: 'd80122be49daa52a',
kind: 0,
timestamp: 1727408111794000,
duration: 27046.959,
timestamp: 1727447640574000,
duration: 20500.166,
attributes: {},
status: { code: 0 },
events: [],
Expand All @@ -81,14 +81,14 @@
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '955a83e23fd481c11e99476809785250',
parentId: '2e4746bd4a491302',
traceId: '9039f59347f6f75a8d39d0b53a9995e0',
parentId: '235586747a904981',
traceState: undefined,
name: 'unpack',
id: '8fbff8ada118f8e4',
id: '0f3bf53d3bb99cfa',
kind: 0,
timestamp: 1727408111822000,
duration: 1130.334,
timestamp: 1727447640594000,
duration: 1112.417,
attributes: {},
status: { code: 0 },
events: [],
Expand All @@ -105,14 +105,14 @@
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '955a83e23fd481c11e99476809785250',
parentId: '2e4746bd4a491302',
traceId: '9039f59347f6f75a8d39d0b53a9995e0',
parentId: '235586747a904981',
traceState: undefined,
name: 'decode',
id: '3c8f702427e6a774',
id: 'cfbb77f628c19bb9',
kind: 0,
timestamp: 1727408111823000,
duration: 194.166,
timestamp: 1727447640596000,
duration: 184.583,
attributes: {},
status: { code: 0 },
events: [],
Expand All @@ -129,14 +129,14 @@
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '955a83e23fd481c11e99476809785250',
traceId: '9039f59347f6f75a8d39d0b53a9995e0',
parentId: undefined,
traceState: undefined,
name: 'request',
id: '2e4746bd4a491302',
id: '235586747a904981',
kind: 0,
timestamp: 1727408111780000,
duration: 43205.584,
timestamp: 1727447640558000,
duration: 37586.041,
attributes: {},
status: { code: 0 },
events: [],
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,9 @@
"homepage": "https://github.com/jasonkuhrt/graffle",
"scripts": {
"serve:pokemon": "tsx tests/_/services/pokemonManual.ts",
"gen:graffle": "pnpm gen:test:schema && pnpm gen:graffle:examples && pnpm build && cd website && pnpm gen:graffle",
"gen:graffle": "tsx tests/_/schemas/generate.ts && pnpm build && cd website && pnpm gen:graffle",
"graffle": "tsx ./src/cli/generate.ts",
"gen:test:schema": "tsx tests/_/schemaGenerate.ts",
"gen:examples": "tsx scripts/generate-examples-derivatives/generate.ts && pnpm format",
"gen:graffle:examples": "tsx './examples/$/schemas/pokemon/generateSdl.ts' && pnpm graffle --name Pokemon --defaultSchemaUrl http://localhost:3000/graphql --schema './examples/$/schemas/pokemon/schema.graphql' --output './examples/$/generated-clients/pokemon' --libraryPathClient ../../../../../src/entrypoints/client.js --libraryPathSchema ../../../../../src/entrypoints/schema.js --libraryPathScalars ../../../../../src/entrypoints/scalars.js --libraryPathUtilitiesForGenerated ../../../../../src/entrypoints/utilities-for-generated.js",
"dev": "rm -rf dist && tsc --watch",
"format": "pnpm build:docs && dprint fmt",
"lint": "eslint . --fix",
Expand Down
16 changes: 2 additions & 14 deletions scripts/generate-examples-derivatives/generate-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const generateExampleLinksSnippets = async (examplesTransformed: ExampleTransfor

const transformRewriteGraffleImports = (example: Example) => {
const newContent = example.file.content
.replaceAll(/from '.+\/tests\/_\/schemas\/(.*)\/graffle\/(.+)\.js'/g, `from './$1/$2.js'`)
.replaceAll(
/from '.*entrypoints\/main.js'/g,
`from 'graffle'`,
Expand All @@ -136,20 +137,7 @@ const transformRewriteGraffleImports = (example: Example) => {
/from '.*entrypoints\/(.*?).js'/g,
`from 'graffle/$1'`,
)
.replaceAll(
/\.js$/g,
``,
)
.replaceAll(
`import { Atlas } from '../$/generated-clients/atlas/__.js'`,
`import { Graffle as Atlas } from './graffle/__.js'`,
)
.replaceAll(
/import ({[^}]+}) from '.*\/generated-clients\/([^/]+)\/__\.js'/g,
`// ---cut---
import $1 from './$2/__.js'`,
)
// Any remaining $ imports are entirely removed.
// Any $ imports are entirely removed.
.replaceAll(/import.*'.*\$.*'\n/g, ``)

return {
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-examples-derivatives/generate-outputs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as FS from 'node:fs/promises'
import * as Path from 'node:path'
import { schema } from '../../examples/$/schemas/pokemon/schema.js'
import { serveSchema } from '../../tests/_/lib/serveSchema.js'
import { schema } from '../../tests/_/schemas/pokemon/schema.js'
import { deleteFiles } from '../lib/deleteFiles.js'
import { directories, readExampleFiles, runExample } from './helpers.js'

Expand Down
6 changes: 3 additions & 3 deletions src/layers/2_SelectionSet/print.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { parse, print } from 'graphql'
import { describe, expect, test } from 'vitest'
import { db } from '../../../tests/_/db.js'
import { $Index as schemaIndex } from '../../../tests/_/schema/generated/modules/SchemaRuntime.js'
import type * as SelectionSets from '../../../tests/_/schema/generated/modules/SelectionSets.js'
import { db } from '../../../tests/_/schemas/db.js'
import { $Index as schemaIndex } from '../../../tests/_/schemas/kitchen-sink/graffle/modules/SchemaRuntime.js'
import type * as SelectionSets from '../../../tests/_/schemas/kitchen-sink/graffle/modules/SelectionSets.js'
import { outputConfigDefault } from '../6_client/Settings/Config.js'
import type { Context } from './print.js'
import { rootType } from './print.js'
Expand Down
2 changes: 1 addition & 1 deletion src/layers/2_SelectionSet/types.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assertType, test } from 'vitest'
import type * as SelectionSets from '../../../tests/_/schema/generated/modules/SelectionSets.js'
import type * as SelectionSets from '../../../tests/_/schemas/kitchen-sink/graffle/modules/SelectionSets.js'

type Q = SelectionSets.Query

Expand Down
4 changes: 2 additions & 2 deletions src/layers/3_ResultSet/decode.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from 'vitest'
import { $Index } from '../../../tests/_/schema/generated/modules/SchemaRuntime.js'
import type * as SelectionSets from '../../../tests/_/schema/generated/modules/SelectionSets.js'
import { $Index } from '../../../tests/_/schemas/kitchen-sink/graffle/modules/SchemaRuntime.js'
import type * as SelectionSets from '../../../tests/_/schemas/kitchen-sink/graffle/modules/SelectionSets.js'
import { decode } from './decode.js'

test.each<[selectionSet: SelectionSets.Query, data: object]>([
Expand Down
6 changes: 3 additions & 3 deletions src/layers/3_ResultSet/infer.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test } from 'vitest'
import type * as Schema from '../../../tests/_/schema/generated/modules/SchemaBuildtime.js'
import type { Index } from '../../../tests/_/schema/generated/modules/SchemaIndex.js'
import type * as SelectionSets from '../../../tests/_/schema/generated/modules/SelectionSets.js'
import type * as Schema from '../../../tests/_/schemas/kitchen-sink/graffle/modules/SchemaBuildtime.js'
import type { Index } from '../../../tests/_/schemas/kitchen-sink/graffle/modules/SchemaIndex.js'
import type * as SelectionSets from '../../../tests/_/schemas/kitchen-sink/graffle/modules/SelectionSets.js'
import { AssertIsEqual } from '../../lib/prelude.js'
import type { ResultSet } from './__.js'

Expand Down
Loading

0 comments on commit 9acf22c

Please sign in to comment.