Skip to content

Commit

Permalink
fix: generated code use given name (#1103)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt authored Sep 18, 2024
1 parent c3559e5 commit c1861d2
Show file tree
Hide file tree
Showing 89 changed files with 1,195 additions and 761 deletions.
3 changes: 3 additions & 0 deletions examples/$/generated-clients/atlas/modules/Data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const Name = `Atlas`

export type Name = 'Atlas'
4 changes: 3 additions & 1 deletion examples/$/generated-clients/atlas/modules/Global.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type * as Data from './Data.js'

import type { Index } from './SchemaIndex.js'

declare global {
export namespace GraffleGlobalTypes {
export interface Schemas {
Atlas: {
name: 'Atlas'
name: Data.Name
index: Index
customScalars: {}
featureOptions: {
Expand Down
60 changes: 30 additions & 30 deletions examples/$/generated-clients/atlas/modules/SchemaBuildtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,42 @@ import type * as $Scalar from './Scalar.ts'
// ------------------------------------------------------------ //

export namespace Root {
export type Query = $.Object$2<'Query', {
export type Query = $.Output.ObjectQuery<{
continent: $.Field<
$.Output.Nullable<Object.Continent>,
$.Args<{
code: $Scalar.ID
}>
code: $.Input.Field<$Scalar.ID>
}, false>
>
continents: $.Field<
$.Output.List<Object.Continent>,
$.Args<{
filter: $.Input.Nullable<InputObject.ContinentFilterInput>
}>
filter: $.Input.Field<$.Input.Nullable<InputObject.ContinentFilterInput>>
}, true>
>
countries: $.Field<
$.Output.List<Object.Country>,
$.Args<{
filter: $.Input.Nullable<InputObject.CountryFilterInput>
}>
filter: $.Input.Field<$.Input.Nullable<InputObject.CountryFilterInput>>
}, true>
>
country: $.Field<
$.Output.Nullable<Object.Country>,
$.Args<{
code: $Scalar.ID
}>
code: $.Input.Field<$Scalar.ID>
}, false>
>
language: $.Field<
$.Output.Nullable<Object.Language>,
$.Args<{
code: $Scalar.ID
}>
code: $.Input.Field<$Scalar.ID>
}, false>
>
languages: $.Field<
$.Output.List<Object.Language>,
$.Args<{
filter: $.Input.Nullable<InputObject.LanguageFilterInput>
}>
filter: $.Input.Field<$.Input.Nullable<InputObject.LanguageFilterInput>>
}, true>
>
}>
}
Expand All @@ -60,27 +60,27 @@ export namespace Enum {

export namespace InputObject {
export type ContinentFilterInput = $.InputObject<'ContinentFilterInput', {
code: $.Input.Nullable<InputObject.StringQueryOperatorInput>
}>
code: $.Input.Field<$.Input.Nullable<InputObject.StringQueryOperatorInput>>
}, true>

export type CountryFilterInput = $.InputObject<'CountryFilterInput', {
code: $.Input.Nullable<InputObject.StringQueryOperatorInput>
continent: $.Input.Nullable<InputObject.StringQueryOperatorInput>
currency: $.Input.Nullable<InputObject.StringQueryOperatorInput>
name: $.Input.Nullable<InputObject.StringQueryOperatorInput>
}>
code: $.Input.Field<$.Input.Nullable<InputObject.StringQueryOperatorInput>>
continent: $.Input.Field<$.Input.Nullable<InputObject.StringQueryOperatorInput>>
currency: $.Input.Field<$.Input.Nullable<InputObject.StringQueryOperatorInput>>
name: $.Input.Field<$.Input.Nullable<InputObject.StringQueryOperatorInput>>
}, true>

export type LanguageFilterInput = $.InputObject<'LanguageFilterInput', {
code: $.Input.Nullable<InputObject.StringQueryOperatorInput>
}>
code: $.Input.Field<$.Input.Nullable<InputObject.StringQueryOperatorInput>>
}, true>

export type StringQueryOperatorInput = $.InputObject<'StringQueryOperatorInput', {
eq: $.Input.Nullable<$Scalar.String>
in: $.Input.Nullable<$.Input.List<$Scalar.String>>
ne: $.Input.Nullable<$Scalar.String>
nin: $.Input.Nullable<$.Input.List<$Scalar.String>>
regex: $.Input.Nullable<$Scalar.String>
}>
eq: $.Input.Field<$.Input.Nullable<$Scalar.String>>
in: $.Input.Field<$.Input.Nullable<$.Input.List<$Scalar.String>>>
ne: $.Input.Field<$.Input.Nullable<$Scalar.String>>
nin: $.Input.Field<$.Input.Nullable<$.Input.List<$Scalar.String>>>
regex: $.Input.Field<$.Input.Nullable<$Scalar.String>>
}, true>
}

// ------------------------------------------------------------ //
Expand Down Expand Up @@ -115,8 +115,8 @@ export namespace Object {
name: $.Field<
$Scalar.String,
$.Args<{
lang: $.Input.Nullable<$Scalar.String>
}>
lang: $.Input.Field<$.Input.Nullable<$Scalar.String>>
}, true>
>
native: $.Field<$Scalar.String, null>
phone: $.Field<$Scalar.String, null>
Expand Down
5 changes: 4 additions & 1 deletion examples/$/generated-clients/atlas/modules/SchemaIndex.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/* eslint-disable */

import type * as Data from './Data.js'

import type * as Schema from './SchemaBuildtime.js'

export interface Index {
name: 'Atlas'
name: Data.Name
RootTypesPresent: ['Query']
RootUnion: Schema.Root.Query
Root: {
Query: Schema.Root.Query
Mutation: null
Expand Down
60 changes: 36 additions & 24 deletions examples/$/generated-clients/atlas/modules/SchemaRuntime.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
/* eslint-disable */

import * as $ from '../../../../../src/entrypoints/schema.js'
import * as Data from './Data.js'
import * as $Scalar from './Scalar.js'
import type { Index } from './SchemaIndex.js'

export const $defaultSchemaUrl = new URL('https://countries.trevorblades.com/graphql')

export const ContinentFilterInput = $.InputObject(`ContinentFilterInput`, {
code: $.Input.field(() => $.Input.Nullable(StringQueryOperatorInput)),
})
code: $.Input.Field(() => $.Input.Nullable(StringQueryOperatorInput)),
}, true)

export const CountryFilterInput = $.InputObject(`CountryFilterInput`, {
code: $.Input.field(() => $.Input.Nullable(StringQueryOperatorInput)),
continent: $.Input.field(() => $.Input.Nullable(StringQueryOperatorInput)),
currency: $.Input.field(() => $.Input.Nullable(StringQueryOperatorInput)),
name: $.Input.field(() => $.Input.Nullable(StringQueryOperatorInput)),
})
code: $.Input.Field(() => $.Input.Nullable(StringQueryOperatorInput)),
continent: $.Input.Field(() => $.Input.Nullable(StringQueryOperatorInput)),
currency: $.Input.Field(() => $.Input.Nullable(StringQueryOperatorInput)),
name: $.Input.Field(() => $.Input.Nullable(StringQueryOperatorInput)),
}, true)

export const LanguageFilterInput = $.InputObject(`LanguageFilterInput`, {
code: $.Input.field(() => $.Input.Nullable(StringQueryOperatorInput)),
})
code: $.Input.Field(() => $.Input.Nullable(StringQueryOperatorInput)),
}, true)

export const StringQueryOperatorInput = $.InputObject(`StringQueryOperatorInput`, {
eq: $.Input.field($.Input.Nullable($Scalar.String)),
in: $.Input.field($.Input.Nullable($.Input.List($Scalar.String))),
ne: $.Input.field($.Input.Nullable($Scalar.String)),
nin: $.Input.field($.Input.Nullable($.Input.List($Scalar.String))),
regex: $.Input.field($.Input.Nullable($Scalar.String)),
})
eq: $.Input.Field($.Input.Nullable($Scalar.String)),
in: $.Input.Field($.Input.Nullable($.Input.List($Scalar.String))),
ne: $.Input.Field($.Input.Nullable($Scalar.String)),
nin: $.Input.Field($.Input.Nullable($.Input.List($Scalar.String))),
regex: $.Input.Field($.Input.Nullable($Scalar.String)),
}, true)

// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
export const Continent = $.Object$(`Continent`, {
Expand All @@ -49,7 +51,7 @@ export const Country = $.Object$(`Country`, {
emojiU: $.field($Scalar.String),
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
languages: $.field($.Output.List(() => Language)),
name: $.field($Scalar.String, $.Args({ lang: $.Input.Nullable($Scalar.String) })),
name: $.field($Scalar.String, $.Args({ lang: $.Input.Field($.Input.Nullable($Scalar.String)) }, true)),
native: $.field($Scalar.String),
phone: $.field($Scalar.String),
phones: $.field($.Output.List($Scalar.String)),
Expand Down Expand Up @@ -85,22 +87,32 @@ export const Subdivision = $.Object$(`Subdivision`, {
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
export const Query = $.Object$(`Query`, {
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
continent: $.field($.Output.Nullable(() => Continent), $.Args({ code: $Scalar.ID })),
continent: $.field($.Output.Nullable(() => Continent), $.Args({ code: $.Input.Field($Scalar.ID) }, false)),
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
continents: $.field($.Output.List(() => Continent), $.Args({ filter: $.Input.Nullable(ContinentFilterInput) })),
continents: $.field(
$.Output.List(() => Continent),
$.Args({ filter: $.Input.Field($.Input.Nullable(ContinentFilterInput)) }, true),
),
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
countries: $.field($.Output.List(() => Country), $.Args({ filter: $.Input.Nullable(CountryFilterInput) })),
countries: $.field(
$.Output.List(() => Country),
$.Args({ filter: $.Input.Field($.Input.Nullable(CountryFilterInput)) }, true),
),
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
country: $.field($.Output.Nullable(() => Country), $.Args({ code: $Scalar.ID })),
country: $.field($.Output.Nullable(() => Country), $.Args({ code: $.Input.Field($Scalar.ID) }, false)),
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
language: $.field($.Output.Nullable(() => Language), $.Args({ code: $Scalar.ID })),
language: $.field($.Output.Nullable(() => Language), $.Args({ code: $.Input.Field($Scalar.ID) }, false)),
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
languages: $.field($.Output.List(() => Language), $.Args({ filter: $.Input.Nullable(LanguageFilterInput) })),
languages: $.field(
$.Output.List(() => Language),
$.Args({ filter: $.Input.Field($.Input.Nullable(LanguageFilterInput)) }, true),
),
})

export const $Index = {
name: 'Atlas' as const,
export const $Index: Index = {
name: Data.Name,
RootTypesPresent: ['Query'] as const,
RootUnion: undefined as any, // Type level only.
Root: {
Query,
Mutation: null,
Expand Down
3 changes: 2 additions & 1 deletion examples/$/generated-clients/atlas/modules/Select.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { ResultSet, SelectionSet } from '../../../../../src/entrypoints/schema.js'
import * as Data from './Data.js'
import type { Index } from './SchemaIndex.js'

// Runtime
// -------

import { createSelect } from '../../../../../src/entrypoints/client.js'
export const Select = createSelect(`default`)
export const Select = createSelect(Data.Name)

// Buildtime
// ---------
Expand Down
3 changes: 3 additions & 0 deletions examples/$/generated-clients/pokemon/modules/Data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const Name = `Pokemon`

export type Name = 'Pokemon'
4 changes: 3 additions & 1 deletion examples/$/generated-clients/pokemon/modules/Global.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type * as Data from './Data.js'

import type { Index } from './SchemaIndex.js'

declare global {
export namespace GraffleGlobalTypes {
export interface Schemas {
Pokemon: {
name: 'Pokemon'
name: Data.Name
index: Index
customScalars: {}
featureOptions: {
Expand Down
22 changes: 11 additions & 11 deletions examples/$/generated-clients/pokemon/modules/SchemaBuildtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@ import type * as $Scalar from './Scalar.ts'
// ------------------------------------------------------------ //

export namespace Root {
export type Mutation = $.Object$2<'Mutation', {
export type Mutation = $.Output.ObjectMutation<{
addPokemon: $.Field<
$.Output.Nullable<Object.Pokemon>,
$.Args<{
attack: $Scalar.Int
defense: $Scalar.Int
hp: $Scalar.Int
name: $Scalar.String
}>
attack: $.Input.Field<$Scalar.Int>
defense: $.Input.Field<$Scalar.Int>
hp: $.Input.Field<$Scalar.Int>
name: $.Input.Field<$Scalar.String>
}, false>
>
}>

export type Query = $.Object$2<'Query', {
export type Query = $.Output.ObjectQuery<{
pokemon: $.Field<$.Output.Nullable<$.Output.List<Object.Pokemon>>, null>
pokemonByName: $.Field<
$.Output.Nullable<$.Output.List<Object.Pokemon>>,
$.Args<{
name: $Scalar.String
}>
name: $.Input.Field<$Scalar.String>
}, false>
>
trainerByName: $.Field<
$.Output.Nullable<Object.Trainer>,
$.Args<{
name: $Scalar.String
}>
name: $.Input.Field<$Scalar.String>
}, false>
>
trainers: $.Field<$.Output.Nullable<$.Output.List<Object.Trainer>>, null>
}>
Expand Down
5 changes: 4 additions & 1 deletion examples/$/generated-clients/pokemon/modules/SchemaIndex.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/* eslint-disable */

import type * as Data from './Data.js'

import type * as Schema from './SchemaBuildtime.js'

export interface Index {
name: 'Pokemon'
name: Data.Name
RootTypesPresent: ['Query', 'Mutation']
RootUnion: Schema.Root.Query | Schema.Root.Mutation
Root: {
Query: Schema.Root.Query
Mutation: Schema.Root.Mutation
Expand Down
21 changes: 16 additions & 5 deletions examples/$/generated-clients/pokemon/modules/SchemaRuntime.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* eslint-disable */

import * as $ from '../../../../../src/entrypoints/schema.js'
import * as Data from './Data.js'
import * as $Scalar from './Scalar.js'
import type { Index } from './SchemaIndex.js'

export const $defaultSchemaUrl = undefined

Expand Down Expand Up @@ -29,7 +31,12 @@ export const Mutation = $.Object$(`Mutation`, {
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
addPokemon: $.field(
$.Output.Nullable(() => Pokemon),
$.Args({ attack: $Scalar.Int, defense: $Scalar.Int, hp: $Scalar.Int, name: $Scalar.String }),
$.Args({
attack: $.Input.Field($Scalar.Int),
defense: $.Input.Field($Scalar.Int),
hp: $.Input.Field($Scalar.Int),
name: $.Input.Field($Scalar.String),
}, false),
),
})

Expand All @@ -38,16 +45,20 @@ export const Query = $.Object$(`Query`, {
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
pokemon: $.field($.Output.Nullable($.Output.List(() => Pokemon))),
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
pokemonByName: $.field($.Output.Nullable($.Output.List(() => Pokemon)), $.Args({ name: $Scalar.String })),
pokemonByName: $.field(
$.Output.Nullable($.Output.List(() => Pokemon)),
$.Args({ name: $.Input.Field($Scalar.String) }, false),
),
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
trainerByName: $.field($.Output.Nullable(() => Trainer), $.Args({ name: $Scalar.String })),
trainerByName: $.field($.Output.Nullable(() => Trainer), $.Args({ name: $.Input.Field($Scalar.String) }, false)),
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
trainers: $.field($.Output.Nullable($.Output.List(() => Trainer))),
})

export const $Index = {
name: 'Pokemon' as const,
export const $Index: Index = {
name: Data.Name,
RootTypesPresent: ['Query', 'Mutation'] as const,
RootUnion: undefined as any, // Type level only.
Root: {
Query,
Mutation,
Expand Down
3 changes: 2 additions & 1 deletion examples/$/generated-clients/pokemon/modules/Select.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { ResultSet, SelectionSet } from '../../../../../src/entrypoints/schema.js'
import * as Data from './Data.js'
import type { Index } from './SchemaIndex.js'

// Runtime
// -------

import { createSelect } from '../../../../../src/entrypoints/client.js'
export const Select = createSelect(`default`)
export const Select = createSelect(Data.Name)

// Buildtime
// ---------
Expand Down
Loading

0 comments on commit c1861d2

Please sign in to comment.