Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(generator): allow controling case of generated client #1229

Merged
merged 20 commits into from
Oct 27, 2024
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 @@ -15,7 +15,7 @@ const graffle = Pokemon
})
.anyware(async ({ exchange }) => {
show(exchange.input.request)
return exchange()
return await exchange()
})

// The following request will use an HTTP POST method because it is
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
"dependencies": {
"@graphql-typed-document-node/core": "^3.2.0",
"@molt/command": "^0.9.0",
"es-toolkit": "^1.26.1",
"is-plain-obj": "^4.1.0"
},
"peerDependencies": {
Expand Down Expand Up @@ -171,7 +172,6 @@
"doctoc": "^2.2.1",
"dprint": "^0.47.4",
"dripip": "^0.10.0",
"es-toolkit": "^1.26.1",
"eslint": "^9.13.0",
"eslint-config-prisma": "^0.6.0",
"eslint-plugin-deprecation": "^3.0.0",
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/documentBuilder/InferResult/__.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Date } from '../../../tests/_/fixtures/scalars.js'
import type { db } from '../../../tests/_/schemas/db.js'
import type { Schema } from '../../../tests/_/schemas/kitchen-sink/graffle/modules/Schema.js'
import type * as SelectionSets from '../../../tests/_/schemas/kitchen-sink/graffle/modules/SelectionSets.js'
import type { Schema } from '../../../tests/_/schemas/kitchen-sink/graffle/modules/schema.js'
import type * as SelectionSets from '../../../tests/_/schemas/kitchen-sink/graffle/modules/selection-sets.js'
import { assertEqual } from '../../lib/assert-equal.js'
import type { Registry } from '../../types/Schema/nodes/Scalar/helpers.js'
import type { InferResult } from './__.js'
Expand Down
4 changes: 2 additions & 2 deletions src/documentBuilder/SelectGraphQLMapper/toGraphQL.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect, test } from 'vitest'
import { Date } from '../../../tests/_/fixtures/scalars.js'
import { db } from '../../../tests/_/schemas/db.js'
import { schemaDrivenDataMap } from '../../../tests/_/schemas/kitchen-sink/graffle/modules/SchemaDrivenDataMap.js'
import type * as SelectionSets from '../../../tests/_/schemas/kitchen-sink/graffle/modules/SelectionSets.js'
import { schemaDrivenDataMap } from '../../../tests/_/schemas/kitchen-sink/graffle/modules/schema-driven-data-map.js'
import type * as SelectionSets from '../../../tests/_/schemas/kitchen-sink/graffle/modules/selection-sets.js'
import { Grafaid } from '../../lib/grafaid/__.js'
import type { Schema } from '../../types/Schema/__.js'
import { Select } from '../Select/__.js'
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/CustomScalars/encode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Date } from '../../../tests/_/fixtures/scalars.js'
import { test } from '../../../tests/_/helpers.js'
import { db } from '../../../tests/_/schemas/db.js'
import type { Graffle } from '../../../tests/_/schemas/kitchen-sink/graffle/__.js'
import { schemaDrivenDataMap } from '../../../tests/_/schemas/kitchen-sink/graffle/modules/SchemaDrivenDataMap.js'
import { schemaDrivenDataMap } from '../../../tests/_/schemas/kitchen-sink/graffle/modules/schema-driven-data-map.js'
import { Spy } from '../../../tests/_/SpyExtension.js'
import { Select } from '../../documentBuilder/Select/__.js'
import { SelectionSetGraphqlMapper } from '../../documentBuilder/SelectGraphQLMapper/__.js'
Expand Down
10 changes: 5 additions & 5 deletions src/extensions/SchemaErrors/tests/fixture/graffle/_.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// It at least helps with Twoslash wherein without this import here Twoslash will not include the global module.
// In real TypeScript projects it seems the global module is included automatically. But there could be certain tsconfig
// setups where this still indeed does help.
import './modules/Global.js'
import './modules/global.js'

export { create } from './modules/Client.js'
export { schemaDrivenDataMap } from './modules/SchemaDrivenDataMap.js'
export { Select } from './modules/Select.js'
export * as SelectionSets from './modules/SelectionSets.js'
export { create } from './modules/client.js'
export { schemaDrivenDataMap } from './modules/schema-driven-data-map.js'
export { Select } from './modules/select.js'
export * as SelectionSets from './modules/selection-sets.js'

This file was deleted.

This file was deleted.

This file was deleted.

158 changes: 0 additions & 158 deletions src/extensions/SchemaErrors/tests/fixture/graffle/modules/Select.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { createPrefilled } from '../../../../../../entrypoints/client.js'
import * as $$Data from './data.js'
import * as $$SchemaDrivenDataMap from './schema-driven-data-map.js'
export const create = createPrefilled($$Data.Name, $$SchemaDrivenDataMap.schemaDrivenDataMap, $$Data.defaultSchemaUrl)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as $$Data from './data.js'
import * as $$MethodsDocument from './methods-document.js'
import * as $$MethodsRoot from './methods-root.js'
import * as $$MethodsSelect from './methods-select.js'
import * as $$Schema from './schema.js'

declare global {
export namespace GraffleGlobal {
export interface Clients {
GraffleSchemaErrors: {
name: $$Data.Name
schema: $$Schema.Schema
interfaces: {
MethodsSelect: $$MethodsSelect.$MethodsSelect
Document: $$MethodsDocument.BuilderMethodsDocumentFn
Root: $$MethodsRoot.BuilderMethodsRootFn
}
defaultSchemaUrl: null
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type * as $$Utilities from '../../../../../../entrypoints/utilities-for-generated.js'
import * as $$Schema from './schema.js'
import * as $$SelectionSets from './selection-sets.js'

export interface Document<$Context extends $$Utilities.ClientContext> {
<$Document>(
document: $$Utilities.ExactNonEmpty<$Document, $$SelectionSets.$Document<$Context['scalars']>>,
): $$Utilities.DocumentRunner<
$Context,
$$Schema.Schema,
// @ts-expect-error We use Exact instead of constraint on this function. TypeScript does not see that as
// Satisfying the constraint on the DocumentRunner type.
$Document
>
}

export interface BuilderMethodsDocumentFn extends $$Utilities.TypeFunction.Fn {
// @ts-expect-error parameter is Untyped.
return: Document<this['params']>
}
Loading