diff --git a/eslint.config.js b/eslint.config.js index f3ad42f05..cac898b4f 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -3,6 +3,8 @@ import tsEslint from 'typescript-eslint' export default tsEslint.config({ ignores: [ + 'playground/**/*', + 'graffle/**/*', 'project/**/*', 'examples/35_custom-scalar/custom-scalar.ts', 'eslint.config.js', diff --git a/src/documentBuilder/InferResult/OutputObject.ts b/src/documentBuilder/InferResult/OutputObject.ts index 5edcfc494..dbecca3f7 100644 --- a/src/documentBuilder/InferResult/OutputObject.ts +++ b/src/documentBuilder/InferResult/OutputObject.ts @@ -6,35 +6,39 @@ import type { Alias } from './Alias.js' import type { OutputField } from './OutputField.js' import type { ScalarsWildcard } from './ScalarsWildcard.js' +// dprint-ignore export type OutputObject<$SelectionSet, $Schema extends Schema, $Node extends Schema.OutputObject> = Select.SelectScalarsWildcard.IsSelectScalarsWildcard<$SelectionSet> extends true // todo what about when scalars wildcard is combined with other fields like relations? ? ScalarsWildcard<$SelectionSet, $Schema, $Node> : SimplifyExcept< - $Schema['scalars']['typesDecoded'], - & SelectionNonSelectAlias<$SelectionSet, $Schema, $Node> - & Alias<$Schema, $Node, $SelectionSet> - > + $Schema['scalars']['typesDecoded'], + & NonAlias<$SelectionSet, $Schema, $Node> + & Alias<$Schema, $Node, $SelectionSet> + > -type SelectionNonSelectAlias<$SelectionSet, $Schema extends Schema, $Node extends Schema.OutputObject> = { +type NonAlias<$SelectionSet, $Schema extends Schema, $Node extends Schema.OutputObject> = { [$Key in PickSelectsPositiveIndicatorAndNotSelectAlias<$SelectionSet>]: $Key extends keyof $Node['fields'] ? OutputField<$SelectionSet[$Key], $Node['fields'][$Key], $Schema> : Errors.UnknownFieldName<$Key, $Node> } -export namespace Errors { - export type UnknownFieldName< - $FieldName extends string, - $Object extends Schema.OutputObject, - > = TSErrorDescriptive<'Object', `field "${$FieldName}" does not exist on object "${$Object['name']}"`> -} - +// dprint-ignore export type PickSelectsPositiveIndicatorAndNotSelectAlias<$SelectionSet> = StringKeyof< { [ - $FieldName in keyof $SelectionSet as $SelectionSet[$FieldName] extends Select.Indicator.Negative ? never - : $SelectionSet[$FieldName] extends any[] ? never - : $FieldName + $FieldName in keyof $SelectionSet as $SelectionSet[$FieldName] extends Select.Indicator.Negative + ? never + : $SelectionSet[$FieldName] extends any[] + ? never + : $FieldName ]: 0 } > + +export namespace Errors { + export type UnknownFieldName< + $FieldName extends string, + $Object extends Schema.OutputObject, + > = TSErrorDescriptive<'Object', `field "${$FieldName}" does not exist on object "${$Object['name']}"`> +}