Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/itchy-swans-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@pothos/plugin-dataloader": patch
"@pothos/plugin-scope-auth": patch
"@pothos/plugin-drizzle": patch
"@pothos/plugin-errors": patch
"@pothos/plugin-prisma": patch
"@pothos/plugin-relay": patch
"@pothos/core": patch
---

Only remove inferrable fields that don't exist on FieldOptions
47 changes: 23 additions & 24 deletions packages/core/src/fieldUtils/builder.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import type {
BaseFieldOptionsFromKind,
CompatibleTypes,
ExposeNullability,
FieldKind,
FieldNullability,
FieldOptionsFromKind,
InferredFieldOptionKeys,
NormalizeArgs,
SchemaTypes,
TypeParam,
Expand All @@ -31,7 +30,7 @@ export class FieldBuilder<
[
options: ExposeNullability<Types, 'Boolean', ParentShape, Name, Nullable> &
Omit<
FieldOptionsFromKind<
BaseFieldOptionsFromKind<
Types,
ParentShape,
'Boolean',
Expand All @@ -41,7 +40,7 @@ export class FieldBuilder<
ParentShape,
ResolveReturnShape
>,
'nullable' | 'type' | InferredFieldOptionKeys
'nullable' | 'type'
>,
]
>
Expand All @@ -66,7 +65,7 @@ export class FieldBuilder<
[
options: ExposeNullability<Types, 'Float', ParentShape, Name, Nullable> &
Omit<
FieldOptionsFromKind<
BaseFieldOptionsFromKind<
Types,
ParentShape,
'Float',
Expand All @@ -76,7 +75,7 @@ export class FieldBuilder<
ParentShape,
ResolveReturnShape
>,
'nullable' | 'type' | InferredFieldOptionKeys
'nullable' | 'type'
>,
]
>
Expand All @@ -101,7 +100,7 @@ export class FieldBuilder<
[
options: ExposeNullability<Types, 'ID', ParentShape, Name, Nullable> &
Omit<
FieldOptionsFromKind<
BaseFieldOptionsFromKind<
Types,
ParentShape,
'ID',
Expand All @@ -111,7 +110,7 @@ export class FieldBuilder<
ParentShape,
ResolveReturnShape
>,
'nullable' | 'type' | InferredFieldOptionKeys
'nullable' | 'type'
>,
]
>
Expand All @@ -136,7 +135,7 @@ export class FieldBuilder<
[
options: ExposeNullability<Types, 'Int', ParentShape, Name, Nullable> &
Omit<
FieldOptionsFromKind<
BaseFieldOptionsFromKind<
Types,
ParentShape,
'Int',
Expand All @@ -146,7 +145,7 @@ export class FieldBuilder<
ParentShape,
ResolveReturnShape
>,
'nullable' | 'type' | InferredFieldOptionKeys
'nullable' | 'type'
>,
]
>
Expand All @@ -171,7 +170,7 @@ export class FieldBuilder<
[
options: ExposeNullability<Types, 'String', ParentShape, Name, Nullable> &
Omit<
FieldOptionsFromKind<
BaseFieldOptionsFromKind<
Types,
ParentShape,
'String',
Expand All @@ -181,7 +180,7 @@ export class FieldBuilder<
ParentShape,
ResolveReturnShape
>,
'nullable' | 'type' | InferredFieldOptionKeys
'nullable' | 'type'
>,
]
>
Expand All @@ -206,7 +205,7 @@ export class FieldBuilder<
[
options: ExposeNullability<Types, ['Boolean'], ParentShape, Name, Nullable> &
Omit<
FieldOptionsFromKind<
BaseFieldOptionsFromKind<
Types,
ParentShape,
['Boolean'],
Expand All @@ -216,7 +215,7 @@ export class FieldBuilder<
ParentShape,
ResolveReturnShape
>,
'nullable' | 'type' | InferredFieldOptionKeys
'nullable' | 'type'
>,
]
>
Expand All @@ -241,7 +240,7 @@ export class FieldBuilder<
[
options: ExposeNullability<Types, ['Float'], ParentShape, Name, Nullable> &
Omit<
FieldOptionsFromKind<
BaseFieldOptionsFromKind<
Types,
ParentShape,
['Float'],
Expand All @@ -251,7 +250,7 @@ export class FieldBuilder<
ParentShape,
ResolveReturnShape
>,
'nullable' | 'type' | InferredFieldOptionKeys
'nullable' | 'type'
>,
]
>
Expand All @@ -276,7 +275,7 @@ export class FieldBuilder<
[
options: ExposeNullability<Types, ['ID'], ParentShape, Name, Nullable> &
Omit<
FieldOptionsFromKind<
BaseFieldOptionsFromKind<
Types,
ParentShape,
['ID'],
Expand All @@ -286,7 +285,7 @@ export class FieldBuilder<
ParentShape,
ResolveReturnShape
>,
'nullable' | 'type' | InferredFieldOptionKeys
'nullable' | 'type'
>,
]
>
Expand All @@ -311,7 +310,7 @@ export class FieldBuilder<
[
options: ExposeNullability<Types, ['Int'], ParentShape, Name, Nullable> &
Omit<
FieldOptionsFromKind<
BaseFieldOptionsFromKind<
Types,
ParentShape,
['Int'],
Expand All @@ -321,7 +320,7 @@ export class FieldBuilder<
ParentShape,
ResolveReturnShape
>,
'nullable' | 'type' | InferredFieldOptionKeys
'nullable' | 'type'
>,
]
>
Expand All @@ -346,7 +345,7 @@ export class FieldBuilder<
[
options: ExposeNullability<Types, ['String'], ParentShape, Name, Nullable> &
Omit<
FieldOptionsFromKind<
BaseFieldOptionsFromKind<
Types,
ParentShape,
['String'],
Expand All @@ -356,7 +355,7 @@ export class FieldBuilder<
ParentShape,
ResolveReturnShape
>,
'nullable' | 'type' | InferredFieldOptionKeys
'nullable' | 'type'
>,
]
>
Expand Down Expand Up @@ -387,7 +386,7 @@ export class FieldBuilder<
[
options: ExposeNullability<Types, Type, ParentShape, Name, Nullable> &
Omit<
FieldOptionsFromKind<
BaseFieldOptionsFromKind<
Types,
ParentShape,
Type,
Expand All @@ -397,7 +396,7 @@ export class FieldBuilder<
ParentShape,
ResolveReturnShape
>,
'nullable' | InferredFieldOptionKeys
'nullable'
>,
]
>
Expand Down
19 changes: 19 additions & 0 deletions packages/core/src/types/builder-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,25 @@ export type FieldOptionsFromKind<
ResolveReturnShape
>[Kind];

export type BaseFieldOptionsFromKind<
Types extends SchemaTypes,
ParentShape,
Type extends TypeParam<Types>,
Nullable extends FieldNullability<Type>,
Args extends InputFieldMap,
Kind extends FieldKind,
ResolveShape,
ResolveReturnShape,
> = PothosSchemaTypes.BaseFieldOptionsByKind<
Types,
ParentShape,
Type,
Nullable,
Args,
ResolveShape,
ResolveReturnShape
>[Kind];

export type ObjectTypeOptions<
Types extends SchemaTypes,
Param extends ObjectParam<Types>,
Expand Down
30 changes: 30 additions & 0 deletions packages/core/src/types/global/field-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,36 @@ declare global {
>;
}

export interface BaseFieldOptionsByKind<
Types extends SchemaTypes,
ParentShape,
Type extends TypeParam<Types>,
Nullable extends FieldNullability<Type>,
Args extends InputFieldMap,
ResolveShape,
ResolveReturnShape,
> {
Query: QueryFieldOptions<Types, Type, Nullable, Args, ResolveReturnShape>;
Mutation: MutationFieldOptions<Types, Type, Nullable, Args, ResolveReturnShape>;
Subscription: SubscriptionFieldOptions<
Types,
Type,
Nullable,
Args,
ResolveShape,
ResolveReturnShape
>;
Object: ObjectFieldOptions<Types, ParentShape, Type, Nullable, Args, ResolveReturnShape>;
Interface: InterfaceFieldOptions<
Types,
ParentShape,
Type,
Nullable,
Args,
ResolveReturnShape
>;
}

export interface InputFieldOptions<
Types extends SchemaTypes = SchemaTypes,
Type extends InputType<Types> | [InputType<Types>] = InputType<Types> | [InputType<Types>],
Expand Down
40 changes: 32 additions & 8 deletions packages/plugin-dataloader/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type {
BaseFieldOptionsFromKind,
DistributeOmit,
FieldKind,
FieldNullability,
FieldOptionsFromKind,
InferredFieldOptionKeys,
InputFieldMap,
InputShapeFromFields,
InterfaceParam,
Expand Down Expand Up @@ -37,9 +37,15 @@ export type LoadableFieldOptions<
CacheKey,
Kind extends FieldKind = FieldKind,
ByPath extends boolean = boolean,
> = Omit<
FieldOptionsFromKind<Types, ParentShape, Type, Nullable, Args, Kind, Key, ResolveReturnShape>,
InferredFieldOptionKeys
> = BaseFieldOptionsFromKind<
Types,
ParentShape,
Type,
Nullable,
Args,
Kind,
Key,
ResolveReturnShape
> & {
byPath?: ByPath;
load: (
Expand Down Expand Up @@ -79,8 +85,17 @@ export type LoadableListFieldOptions<
Kind extends FieldKind = FieldKind,
ByPath extends boolean = boolean,
> = Omit<
FieldOptionsFromKind<Types, ParentShape, [Type], Nullable, Args, Kind, Key, ResolveReturnShape>,
InferredFieldOptionKeys | 'type'
BaseFieldOptionsFromKind<
Types,
ParentShape,
[Type],
Nullable,
Args,
Kind,
Key,
ResolveReturnShape
>,
'type'
> & {
type: Type;
byPath?: ByPath;
Expand Down Expand Up @@ -113,8 +128,17 @@ export type LoadableGroupFieldOptions<
Kind extends FieldKind = FieldKind,
ByPath extends boolean = boolean,
> = Omit<
FieldOptionsFromKind<Types, ParentShape, [Type], Nullable, Args, Kind, Key, ResolveReturnShape>,
InferredFieldOptionKeys | 'type'
BaseFieldOptionsFromKind<
Types,
ParentShape,
[Type],
Nullable,
Args,
Kind,
Key,
ResolveReturnShape
>,
'type'
> & {
type: Type;
byPath?: ByPath;
Expand Down
5 changes: 2 additions & 3 deletions packages/plugin-drizzle/src/drizzle-field-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
type ExposeNullability,
type FieldKind,
type FieldRef,
type InferredFieldOptionKeys,
type InputFieldMap,
type InterfaceParam,
isThenable,
Expand Down Expand Up @@ -455,7 +454,7 @@ export class DrizzleObjectFieldBuilder<
{},
ResolveReturnShape
>,
'nullable' | 'select' | InferredFieldOptionKeys
'nullable' | 'select'
>,
]
>
Expand Down Expand Up @@ -501,7 +500,7 @@ export class DrizzleObjectFieldBuilder<
{},
ResolveReturnShape
>,
'nullable' | 'select' | 'type' | InferredFieldOptionKeys
'nullable' | 'select' | 'type'
> & {
description?: string | false;
},
Expand Down
Loading
Loading