Skip to content

Commit

Permalink
feat(generator): separate name and namespace name config (#1235)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt authored Oct 28, 2024
1 parent e0f7492 commit c7f7dc5
Show file tree
Hide file tree
Showing 654 changed files with 30,930 additions and 47,427 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/deploy-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ jobs:
id: deployment
uses: actions/deploy-pages@v4

# TODO Go back to building website in CI and NOT committing the dist to the repo.
# Currently, the Twoslash results in CI are not consistent with local results.
# E.g. We'll get some variable as `any` in CI versus an actual data type in local.

# name: Deploy Website
# on:
# push:
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"**/build": true,
"**/__snapshots__": true,
"**/pnpm-lock.yaml": true,
"**/*.tsbuildinfo": true
"**/*.tsbuildinfo": true,
"**/.vitepress/dist": true
},
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
Expand Down
3 changes: 2 additions & 1 deletion dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"**/node_modules",
"**/*-lock.json",
"website/pokemon",
"website/graffle"
"website/graffle",
"website/.vitepress/dist"
],
"plugins": [
"https://plugins.dprint.dev/typescript-0.93.0.wasm",
Expand Down
4 changes: 2 additions & 2 deletions examples/10_transport-http/transport-http_method-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* to be sent over HTTP GET method. Note write-kind operations (mutation) are still sent over HTTP POST method.
*/

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

const graffle = Pokemon
const graffle = Graffle
.create({
transport: {
methodMode: `getReads`, // [!code highlight]
Expand Down
4 changes: 2 additions & 2 deletions examples/20_output/output_default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* This example shows the default output behavior.
*/

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

const pokemon = Pokemon.create()
const pokemon = Graffle.create()

const pokemons = await pokemon.query.pokemons({ name: true })

Expand Down
4 changes: 2 additions & 2 deletions examples/20_output/output_envelope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* This example shows how to configure output to use the envelope.
*/

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

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

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

// dprint-ignore
const pokemon = Pokemon
const pokemon = Graffle
.create({
output: {
envelope: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* This example shows how to configure output to throw errors even when using the envelope.
*/

import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { Graffle } from '../../tests/_/schemas/pokemon/graffle/__.js'

// dprint-ignore
const pokemon = Pokemon
const pokemon = Graffle
.create({
output: {
envelope: {
Expand Down
4 changes: 2 additions & 2 deletions examples/20_output/output_return-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* This example shows how to configure output to have errors returned instead of e.g. thrown.
*/

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

// dprint-ignore
const pokemon = Pokemon
const pokemon = Graffle
.create({
output: {
envelope: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* This example shows how to configure output to have only certain kinds of errors returned while others thrown.
*/

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

const pokemon = Pokemon
const pokemon = Graffle
.create({
output: {
envelope: false,
Expand Down
4 changes: 2 additions & 2 deletions examples/35_custom-scalar/custom-scalar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* have arguments and data automatically encoded and decoded respectively.
*/

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

const graffle = Pokemon
const graffle = Graffle
.create()
.scalar(`Date`, {
decode: (value: string) => new Date(value),
Expand Down
4 changes: 2 additions & 2 deletions examples/55_document-builder/document-builder_alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* This example shows how to write GraphQL aliases in the TypeScript interface.
*/

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

const pokemon = Pokemon.create()
const pokemon = Graffle.create()

const day = 1000 * 60 * 60 * 24
const year = day * 365.25
Expand Down
4 changes: 2 additions & 2 deletions examples/55_document-builder/document-builder_arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* This example shows how to write field arguments in TypeScript interface.
*/

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

const atlas = Pokemon.create()
const atlas = Graffle.create()

// dprint-ignore
const pokemons = await atlas.query.pokemons({
Expand Down
4 changes: 2 additions & 2 deletions examples/55_document-builder/document-builder_batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* This example shows how to write batches of GraphQL root fields (aka. entrypoints) in the TypeScript interface.
*/

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

const pokemon = Pokemon.create()
const pokemon = Graffle.create()

// dprint-ignore
const pokemons = await pokemon.query.$batch({
Expand Down
4 changes: 2 additions & 2 deletions examples/55_document-builder/document-builder_directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
*/

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

const pokemon = Pokemon.create()
const pokemon = Graffle.create()

// dprint-ignore
const pokemons = await pokemon.query.$batch({
Expand Down
4 changes: 2 additions & 2 deletions examples/55_document-builder/document-builder_document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* This example shows how to write whole GraphQL documents in the TypeScript interface.
*/

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

const pokemon = Pokemon.create()
const pokemon = Graffle.create()

const pokemons = await pokemon.document({
// ^^^^^^^^
Expand Down
4 changes: 2 additions & 2 deletions examples/55_document-builder/document-builder_interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* This example shows how to work with interface types.
*/

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

const pokemon = Pokemon.create()
const pokemon = Graffle.create()

// dprint-ignore
const beings = await pokemon.query.beings({
Expand Down
4 changes: 2 additions & 2 deletions examples/55_document-builder/document-builder_root-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* 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 '../../tests/_/schemas/pokemon/graffle/__.js'
import { Graffle } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { showJson } from '../$/helpers.js'

const pokemon = Pokemon.create()
const pokemon = Graffle.create()

const pokemons = await pokemon.query.pokemons({ name: true })
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
4 changes: 2 additions & 2 deletions examples/55_document-builder/document-builder_union.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* This example shows how to work with GraphQL union types in the TypeScript interface.
*/

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

const pokemon = Pokemon.create()
const pokemon = Graffle.create()

// dprint-ignore
const battles = await pokemon.query.battles({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
*/

import { Introspection } from '../../src/entrypoints/extensions/introspection/runtime.js'
import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { Graffle } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { interceptAndShowUncaughtErrors, show } from '../$/show.js'

interceptAndShowUncaughtErrors()

const pokemon = Pokemon.create().use(Introspection())
const pokemon = Graffle.create().use(Introspection())

const data = await pokemon.introspect()
show(data)
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/opentelemetry/runtime.js'
import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { Graffle } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { interceptAndShowOutput, show } from '../$/helpers.js'

interceptAndShowOutput()
Expand All @@ -15,6 +15,6 @@ const provider = new NodeTracerProvider()
provider.addSpanProcessor(processor)
provider.register()

const graffle = Pokemon.create().use(Opentelemetry())
const graffle = Graffle.create().use(Opentelemetry())
const data = await graffle.gql`query { pokemons { name } }`.send()
show(data)
4 changes: 2 additions & 2 deletions examples/60_extension/extension_throws__throws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
*/

import { Throws } from '../../src/entrypoints/extensions/throws/runtime.js'
import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { Graffle } from '../../tests/_/schemas/pokemon/graffle/__.js'
import { interceptAndShowUncaughtErrors, show } from '../$/show.js'

interceptAndShowUncaughtErrors()

const pokemon = Pokemon
const pokemon = Graffle
.create({ output: { defaults: { errorChannel: `return` } } })
.use(Throws())
.anyware(({ encode: _ }) => {
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': '1730084002612'
'x-sent-at-time': '1730125688291'
},
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': '142',
date: 'Mon, 28 Oct 2024 02:53:23 GMT',
date: 'Mon, 28 Oct 2024 14:28:09 GMT',
connection: 'keep-alive',
'keep-alive': 'timeout=5'
},
Expand Down
Loading

0 comments on commit c7f7dc5

Please sign in to comment.