Skip to content

Commit

Permalink
regen
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Oct 21, 2024
1 parent c27e63e commit 0e74e84
Show file tree
Hide file tree
Showing 11 changed files with 331 additions and 335 deletions.

Large diffs are not rendered by default.

102 changes: 51 additions & 51 deletions src/generator/generator/__snapshots__/generate.test.ts.snap

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions src/generator/generators/SelectionSets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,9 @@ const renderKindOutputObject = createCodeGenerator<{ type: Grafaid.Schema.Object
code()

const fieldKeys = fields.map(field => {
const fieldTypeInfo = Grafaid.getTypeAndKind(Grafaid.Schema.getNamedType(field.type))
const fieldTypeKindOrScalarType = fieldTypeInfo.kindName === Grafaid.Schema.KindMap.Name.ScalarCustom
|| fieldTypeInfo.kindName === Grafaid.Schema.KindMap.Name.ScalarStandard
? `\`${fieldTypeInfo.name}\` (a \`Scalar\`)`
: fieldTypeInfo.kindName
const typeKind = Grafaid.getTypeAndKind(Grafaid.Schema.getNamedType(field.type))
const doc = Code.TSDoc(`
Select the \`${field.name}\` field on the \`${type.name}\` object. Its type is ${fieldTypeKindOrScalarType}.
Select the \`${field.name}\` field on the \`${type.name}\` object. Its type is \`${typeKind.typeName}\` (a \`${typeKind.kindName}\` kind of type).
`)
const key = H.outputFieldKey(
field.name,
Expand Down
2 changes: 1 addition & 1 deletion src/generator/helpers/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const title1 = (title: string, subTitle?: string) => {
export const typeTitle2 = (category: string) => (type: Grafaid.Schema.NamedTypes) => {
const typeKind = Grafaid.getTypeAndKind(type)
const nameOrKind = typeKind.kindName === `ScalarCustom` || typeKind.kindName === `ScalarStandard`
? typeKind.name
? typeKind.typeName
: typeKind.kindName
const typeLabel = nameOrKind
const title = `
Expand Down
6 changes: 3 additions & 3 deletions src/lib/grafaid/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ export const isStandardScalarType = (type: GraphQLScalarType) => {
export const getTypeAndKind = (
node: GraphQLNamedType,
): {
name: string
typeName: string
kindName: KindMap.KindName
} => {
const name = node.name
const typeName = node.name

let kindName: KindMap.KindName

Expand All @@ -92,5 +92,5 @@ export const getTypeAndKind = (
} else {
throw casesExhausted(node)
}
return { name, kindName }
return { typeName, kindName }
}
150 changes: 75 additions & 75 deletions tests/_/schemas/kitchen-sink/graffle/modules/SelectionSets.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ export interface $Document<$Scalars extends $$Utilities.Schema.Scalar.ScalarMap

export interface Mutation<$Scalars extends $$Utilities.Schema.Scalar.ScalarMap = {}> {
/**
* Select the `id` field on the `Mutation` object. Its type is `ID` (a `Scalar`).
* Select the `id` field on the `Mutation` object. Its type is `ID` (a `ScalarStandard` kind of type).
*/
id?: Mutation.id$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Mutation.id<$Scalars>>
/**
* Select the `idNonNull` field on the `Mutation` object. Its type is `ID` (a `Scalar`).
* Select the `idNonNull` field on the `Mutation` object. Its type is `ID` (a `ScalarStandard` kind of type).
*/
idNonNull?: Mutation.idNonNull$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Mutation.idNonNull<$Scalars>>

Expand Down
86 changes: 43 additions & 43 deletions tests/_/schemas/pokemon/graffle/modules/SelectionSets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export interface $Document<$Scalars extends $$Utilities.Schema.Scalar.ScalarMap

export interface Mutation<$Scalars extends $$Utilities.Schema.Scalar.ScalarMap = {}> {
/**
* Select the `addPokemon` field on the `Mutation` object. Its type is OutputObject.
* Select the `addPokemon` field on the `Mutation` object. Its type is `Pokemon` (a `OutputObject` kind of type).
*/
addPokemon?: Mutation.addPokemon<$Scalars> | $Select.SelectAlias.SelectAlias<Mutation.addPokemon<$Scalars>>

Expand Down Expand Up @@ -135,31 +135,31 @@ export namespace Mutation {

export interface Query<$Scalars extends $$Utilities.Schema.Scalar.ScalarMap = {}> {
/**
* Select the `battles` field on the `Query` object. Its type is Union.
* Select the `battles` field on the `Query` object. Its type is `Battle` (a `Union` kind of type).
*/
battles?: Query.battles$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Query.battles<$Scalars>>
/**
* Select the `beings` field on the `Query` object. Its type is Interface.
* Select the `beings` field on the `Query` object. Its type is `Being` (a `Interface` kind of type).
*/
beings?: Query.beings$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Query.beings<$Scalars>>
/**
* Select the `pokemon` field on the `Query` object. Its type is OutputObject.
* Select the `pokemon` field on the `Query` object. Its type is `Pokemon` (a `OutputObject` kind of type).
*/
pokemon?: Query.pokemon$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Query.pokemon<$Scalars>>
/**
* Select the `pokemonByName` field on the `Query` object. Its type is OutputObject.
* Select the `pokemonByName` field on the `Query` object. Its type is `Pokemon` (a `OutputObject` kind of type).
*/
pokemonByName?: Query.pokemonByName<$Scalars> | $Select.SelectAlias.SelectAlias<Query.pokemonByName<$Scalars>>
/**
* Select the `pokemons` field on the `Query` object. Its type is OutputObject.
* Select the `pokemons` field on the `Query` object. Its type is `Pokemon` (a `OutputObject` kind of type).
*/
pokemons?: Query.pokemons$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Query.pokemons<$Scalars>>
/**
* Select the `trainerByName` field on the `Query` object. Its type is OutputObject.
* Select the `trainerByName` field on the `Query` object. Its type is `Trainer` (a `OutputObject` kind of type).
*/
trainerByName?: Query.trainerByName<$Scalars> | $Select.SelectAlias.SelectAlias<Query.trainerByName<$Scalars>>
/**
* Select the `trainers` field on the `Query` object. Its type is OutputObject.
* Select the `trainers` field on the `Query` object. Its type is `Trainer` (a `OutputObject` kind of type).
*/
trainers?: Query.trainers$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Query.trainers<$Scalars>>

Expand Down Expand Up @@ -455,21 +455,21 @@ export interface BattleRoyale<$Scalars extends $$Utilities.Schema.Scalar.ScalarM
extends $Select.Bases.ObjectLike
{
/**
* Select the `combatants` field on the `BattleRoyale` object. Its type is OutputObject.
* Select the `combatants` field on the `BattleRoyale` object. Its type is `CombatantMultiPokemon` (a `OutputObject` kind of type).
*/
combatants?:
| BattleRoyale.combatants$Expanded<$Scalars>
| $Select.SelectAlias.SelectAlias<BattleRoyale.combatants<$Scalars>>
/**
* Select the `date` field on the `BattleRoyale` object. Its type is `Float` (a `Scalar`).
* Select the `date` field on the `BattleRoyale` object. Its type is `Float` (a `ScalarStandard` kind of type).
*/
date?: BattleRoyale.date$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<BattleRoyale.date<$Scalars>>
/**
* Select the `id` field on the `BattleRoyale` object. Its type is `ID` (a `Scalar`).
* Select the `id` field on the `BattleRoyale` object. Its type is `ID` (a `ScalarStandard` kind of type).
*/
id?: BattleRoyale.id$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<BattleRoyale.id<$Scalars>>
/**
* Select the `winner` field on the `BattleRoyale` object. Its type is OutputObject.
* Select the `winner` field on the `BattleRoyale` object. Its type is `Trainer` (a `OutputObject` kind of type).
*/
winner?: BattleRoyale.winner$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<BattleRoyale.winner<$Scalars>>

Expand Down Expand Up @@ -601,27 +601,27 @@ export interface BattleTrainer<$Scalars extends $$Utilities.Schema.Scalar.Scalar
extends $Select.Bases.ObjectLike
{
/**
* Select the `combatant1` field on the `BattleTrainer` object. Its type is OutputObject.
* Select the `combatant1` field on the `BattleTrainer` object. Its type is `CombatantSinglePokemon` (a `OutputObject` kind of type).
*/
combatant1?:
| BattleTrainer.combatant1$Expanded<$Scalars>
| $Select.SelectAlias.SelectAlias<BattleTrainer.combatant1<$Scalars>>
/**
* Select the `combatant2` field on the `BattleTrainer` object. Its type is OutputObject.
* Select the `combatant2` field on the `BattleTrainer` object. Its type is `CombatantSinglePokemon` (a `OutputObject` kind of type).
*/
combatant2?:
| BattleTrainer.combatant2$Expanded<$Scalars>
| $Select.SelectAlias.SelectAlias<BattleTrainer.combatant2<$Scalars>>
/**
* Select the `date` field on the `BattleTrainer` object. Its type is `Float` (a `Scalar`).
* Select the `date` field on the `BattleTrainer` object. Its type is `Float` (a `ScalarStandard` kind of type).
*/
date?: BattleTrainer.date$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<BattleTrainer.date<$Scalars>>
/**
* Select the `id` field on the `BattleTrainer` object. Its type is `ID` (a `Scalar`).
* Select the `id` field on the `BattleTrainer` object. Its type is `ID` (a `ScalarStandard` kind of type).
*/
id?: BattleTrainer.id$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<BattleTrainer.id<$Scalars>>
/**
* Select the `winner` field on the `BattleTrainer` object. Its type is OutputObject.
* Select the `winner` field on the `BattleTrainer` object. Its type is `Trainer` (a `OutputObject` kind of type).
*/
winner?: BattleTrainer.winner$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<BattleTrainer.winner<$Scalars>>

Expand Down Expand Up @@ -772,27 +772,27 @@ export interface BattleWild<$Scalars extends $$Utilities.Schema.Scalar.ScalarMap
extends $Select.Bases.ObjectLike
{
/**
* Select the `date` field on the `BattleWild` object. Its type is `Float` (a `Scalar`).
* Select the `date` field on the `BattleWild` object. Its type is `Float` (a `ScalarStandard` kind of type).
*/
date?: BattleWild.date$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<BattleWild.date<$Scalars>>
/**
* Select the `id` field on the `BattleWild` object. Its type is `ID` (a `Scalar`).
* Select the `id` field on the `BattleWild` object. Its type is `ID` (a `ScalarStandard` kind of type).
*/
id?: BattleWild.id$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<BattleWild.id<$Scalars>>
/**
* Select the `pokemon` field on the `BattleWild` object. Its type is OutputObject.
* Select the `pokemon` field on the `BattleWild` object. Its type is `Pokemon` (a `OutputObject` kind of type).
*/
pokemon?: BattleWild.pokemon$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<BattleWild.pokemon<$Scalars>>
/**
* Select the `result` field on the `BattleWild` object. Its type is Enum.
* Select the `result` field on the `BattleWild` object. Its type is `BattleWildResult` (a `Enum` kind of type).
*/
result?: BattleWild.result$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<BattleWild.result<$Scalars>>
/**
* Select the `trainer` field on the `BattleWild` object. Its type is OutputObject.
* Select the `trainer` field on the `BattleWild` object. Its type is `Trainer` (a `OutputObject` kind of type).
*/
trainer?: BattleWild.trainer$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<BattleWild.trainer<$Scalars>>
/**
* Select the `wildPokemons` field on the `BattleWild` object. Its type is OutputObject.
* Select the `wildPokemons` field on the `BattleWild` object. Its type is `Pokemon` (a `OutputObject` kind of type).
*/
wildPokemons?:
| BattleWild.wildPokemons$Expanded<$Scalars>
Expand Down Expand Up @@ -969,13 +969,13 @@ export interface CombatantMultiPokemon<$Scalars extends $$Utilities.Schema.Scala
extends $Select.Bases.ObjectLike
{
/**
* Select the `pokemons` field on the `CombatantMultiPokemon` object. Its type is OutputObject.
* Select the `pokemons` field on the `CombatantMultiPokemon` object. Its type is `Pokemon` (a `OutputObject` kind of type).
*/
pokemons?:
| CombatantMultiPokemon.pokemons$Expanded<$Scalars>
| $Select.SelectAlias.SelectAlias<CombatantMultiPokemon.pokemons<$Scalars>>
/**
* Select the `trainer` field on the `CombatantMultiPokemon` object. Its type is OutputObject.
* Select the `trainer` field on the `CombatantMultiPokemon` object. Its type is `Trainer` (a `OutputObject` kind of type).
*/
trainer?:
| CombatantMultiPokemon.trainer$Expanded<$Scalars>
Expand Down Expand Up @@ -1065,13 +1065,13 @@ export interface CombatantSinglePokemon<$Scalars extends $$Utilities.Schema.Scal
extends $Select.Bases.ObjectLike
{
/**
* Select the `pokemon` field on the `CombatantSinglePokemon` object. Its type is OutputObject.
* Select the `pokemon` field on the `CombatantSinglePokemon` object. Its type is `Pokemon` (a `OutputObject` kind of type).
*/
pokemon?:
| CombatantSinglePokemon.pokemon$Expanded<$Scalars>
| $Select.SelectAlias.SelectAlias<CombatantSinglePokemon.pokemon<$Scalars>>
/**
* Select the `trainer` field on the `CombatantSinglePokemon` object. Its type is OutputObject.
* Select the `trainer` field on the `CombatantSinglePokemon` object. Its type is `Trainer` (a `OutputObject` kind of type).
*/
trainer?:
| CombatantSinglePokemon.trainer$Expanded<$Scalars>
Expand Down Expand Up @@ -1159,15 +1159,15 @@ export namespace CombatantSinglePokemon {

export interface Patron<$Scalars extends $$Utilities.Schema.Scalar.ScalarMap = {}> extends $Select.Bases.ObjectLike {
/**
* Select the `id` field on the `Patron` object. Its type is `ID` (a `Scalar`).
* Select the `id` field on the `Patron` object. Its type is `ID` (a `ScalarStandard` kind of type).
*/
id?: Patron.id$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Patron.id<$Scalars>>
/**
* Select the `money` field on the `Patron` object. Its type is `Int` (a `Scalar`).
* Select the `money` field on the `Patron` object. Its type is `Int` (a `ScalarStandard` kind of type).
*/
money?: Patron.money$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Patron.money<$Scalars>>
/**
* Select the `name` field on the `Patron` object. Its type is `String` (a `Scalar`).
* Select the `name` field on the `Patron` object. Its type is `String` (a `ScalarStandard` kind of type).
*/
name?: Patron.name$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Patron.name<$Scalars>>

Expand Down Expand Up @@ -1281,35 +1281,35 @@ export namespace Patron {

export interface Pokemon<$Scalars extends $$Utilities.Schema.Scalar.ScalarMap = {}> extends $Select.Bases.ObjectLike {
/**
* Select the `attack` field on the `Pokemon` object. Its type is `Int` (a `Scalar`).
* Select the `attack` field on the `Pokemon` object. Its type is `Int` (a `ScalarStandard` kind of type).
*/
attack?: Pokemon.attack$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Pokemon.attack<$Scalars>>
/**
* Select the `birthday` field on the `Pokemon` object. Its type is `Int` (a `Scalar`).
* Select the `birthday` field on the `Pokemon` object. Its type is `Int` (a `ScalarStandard` kind of type).
*/
birthday?: Pokemon.birthday$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Pokemon.birthday<$Scalars>>
/**
* Select the `defense` field on the `Pokemon` object. Its type is `Int` (a `Scalar`).
* Select the `defense` field on the `Pokemon` object. Its type is `Int` (a `ScalarStandard` kind of type).
*/
defense?: Pokemon.defense$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Pokemon.defense<$Scalars>>
/**
* Select the `hp` field on the `Pokemon` object. Its type is `Int` (a `Scalar`).
* Select the `hp` field on the `Pokemon` object. Its type is `Int` (a `ScalarStandard` kind of type).
*/
hp?: Pokemon.hp$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Pokemon.hp<$Scalars>>
/**
* Select the `id` field on the `Pokemon` object. Its type is `ID` (a `Scalar`).
* Select the `id` field on the `Pokemon` object. Its type is `ID` (a `ScalarStandard` kind of type).
*/
id?: Pokemon.id$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Pokemon.id<$Scalars>>
/**
* Select the `name` field on the `Pokemon` object. Its type is `String` (a `Scalar`).
* Select the `name` field on the `Pokemon` object. Its type is `String` (a `ScalarStandard` kind of type).
*/
name?: Pokemon.name$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Pokemon.name<$Scalars>>
/**
* Select the `trainer` field on the `Pokemon` object. Its type is OutputObject.
* Select the `trainer` field on the `Pokemon` object. Its type is `Trainer` (a `OutputObject` kind of type).
*/
trainer?: Pokemon.trainer$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Pokemon.trainer<$Scalars>>
/**
* Select the `type` field on the `Pokemon` object. Its type is Enum.
* Select the `type` field on the `Pokemon` object. Its type is `PokemonType` (a `Enum` kind of type).
*/
type?: Pokemon.type$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Pokemon.type<$Scalars>>

Expand Down Expand Up @@ -1530,23 +1530,23 @@ export namespace Pokemon {

export interface Trainer<$Scalars extends $$Utilities.Schema.Scalar.ScalarMap = {}> extends $Select.Bases.ObjectLike {
/**
* Select the `class` field on the `Trainer` object. Its type is Enum.
* Select the `class` field on the `Trainer` object. Its type is `TrainerClass` (a `Enum` kind of type).
*/
class?: Trainer.$class$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Trainer.$class<$Scalars>>
/**
* Select the `fans` field on the `Trainer` object. Its type is OutputObject.
* Select the `fans` field on the `Trainer` object. Its type is `Patron` (a `OutputObject` kind of type).
*/
fans?: Trainer.fans$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Trainer.fans<$Scalars>>
/**
* Select the `id` field on the `Trainer` object. Its type is `ID` (a `Scalar`).
* Select the `id` field on the `Trainer` object. Its type is `ID` (a `ScalarStandard` kind of type).
*/
id?: Trainer.id$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Trainer.id<$Scalars>>
/**
* Select the `name` field on the `Trainer` object. Its type is `String` (a `Scalar`).
* Select the `name` field on the `Trainer` object. Its type is `String` (a `ScalarStandard` kind of type).
*/
name?: Trainer.name$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Trainer.name<$Scalars>>
/**
* Select the `pokemon` field on the `Trainer` object. Its type is OutputObject.
* Select the `pokemon` field on the `Trainer` object. Its type is `Pokemon` (a `OutputObject` kind of type).
*/
pokemon?: Trainer.pokemon$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Trainer.pokemon<$Scalars>>

Expand Down
4 changes: 2 additions & 2 deletions tests/_/schemas/query-only/graffle/modules/SelectionSets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ export interface $Document<$Scalars extends $$Utilities.Schema.Scalar.ScalarMap

export interface Query<$Scalars extends $$Utilities.Schema.Scalar.ScalarMap = {}> {
/**
* Select the `id` field on the `Query` object. Its type is `ID` (a `Scalar`).
* Select the `id` field on the `Query` object. Its type is `ID` (a `ScalarStandard` kind of type).
*/
id?: Query.id$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Query.id<$Scalars>>
/**
* Select the `idNonNull` field on the `Query` object. Its type is `ID` (a `Scalar`).
* Select the `idNonNull` field on the `Query` object. Its type is `ID` (a `ScalarStandard` kind of type).
*/
idNonNull?: Query.idNonNull$Expanded<$Scalars> | $Select.SelectAlias.SelectAlias<Query.idNonNull<$Scalars>>

Expand Down
Loading

0 comments on commit 0e74e84

Please sign in to comment.