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

[spike] add scaffold for new validation plugin #1373

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion examples/complex-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"prisma": "^6.0.0",
"react": "^18.3.1",
"urql": "^4.2.1",
"zod": "^3.23.8"
"zod": "^3.24.1"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"provenance": true
},
"peerDependencies": {
"graphql": ">=16.6.0"
"graphql": "^16.8.1"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an annoying artifact of how pnpm upgrade -irL works with peer dependencies, and needs to be reverted

},
"devDependencies": {
"@pothos/test-utils": "workspace:*",
Expand Down
38 changes: 35 additions & 3 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@ import { ListRef as InternalListRef } from './refs/list';
import { ObjectRef as InternalObjectRef } from './refs/object';
import { ScalarRef as InternalScalarRef } from './refs/scalar';
import { UnionRef as InternalUnionRef } from './refs/union';
import { FieldRef as InternalFieldRef } from './refs/field';
import { InputFieldRef as InternalInputFieldRef } from './refs/input-field';
import { ArgumentRef as InternalArgumentRef } from './refs/arg';

import type {
AddVersionedDefaultsToBuilderOptions,
FieldKind,
InputTypeParam,
NormalizeSchemeBuilderOptions,
PothosInputFieldConfig,
PothosOutputFieldConfig,
PothosTypeConfig,
RootName,
SchemaTypes,
TypeParam,
Expand Down Expand Up @@ -203,12 +210,37 @@ export const ListRef = InternalListRef as new <Types extends SchemaTypes, T, P =
nullable: boolean,
) => PothosSchemaTypes.ListRef<Types, T, P>;

export type FieldRef<
Types extends SchemaTypes,
T = unknown,
Kind extends FieldKind = FieldKind,
> = PothosSchemaTypes.FieldRef<Types, T, Kind>;
export const FieldRef = InternalFieldRef as new <
Types extends SchemaTypes,
T = unknown,
Kind extends FieldKind = FieldKind,
>(
kind: Kind,
initConfig: (name: string, typeConfig: PothosTypeConfig) => PothosOutputFieldConfig<Types>,
) => PothosSchemaTypes.FieldRef<Types, T, Kind>;

export type InputFieldRef<Types extends SchemaTypes, T> = PothosSchemaTypes.InputFieldRef<Types, T>;
export const InputFieldRef = InternalInputFieldRef as new <Types extends SchemaTypes, T>(
initConfig: (name: string, typeConfig: PothosTypeConfig) => PothosInputFieldConfig<Types>,
) => PothosSchemaTypes.InputFieldRef<Types, T>;

export type ArgumentRef<Types extends SchemaTypes, T> = PothosSchemaTypes.ArgumentRef<Types, T>;
export const ArgumentRef = InternalArgumentRef as new <Types extends SchemaTypes, T>(
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just makes it so these types of Refs can be more easily extended by plugins

initConfig: (
name: string,
field: string,
typeConfig: PothosTypeConfig,
) => PothosInputFieldConfig<Types>,
) => PothosSchemaTypes.ArgumentRef<Types, T>;

export { BuildCache } from './build-cache';
export { ArgumentRef } from './refs/arg';
export { BuiltinScalarRef } from './refs/builtin-scalar';
export { FieldRef } from './refs/field';
export { InputTypeRef } from './refs/input';
export { InputFieldRef } from './refs/input-field';
export { ImplementableInputObjectRef } from './refs/input-object';
export { ImplementableInterfaceRef } from './refs/interface';
export { MutationRef } from './refs/mutation';
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/refs/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import {
outputFieldShapeKey,
} from '../types';

export class FieldRef<Types extends SchemaTypes, T = unknown, Kind extends FieldKind = FieldKind> {
export class FieldRef<Types extends SchemaTypes, T = unknown, Kind extends FieldKind = FieldKind>
implements PothosSchemaTypes.FieldRef<Types, T, Kind>
{
kind: FieldKind;

fieldName?: string;
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/refs/input-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import {
inputFieldShapeKey,
} from '../types';

export class InputFieldRef<Types extends SchemaTypes, T = unknown> {
export class InputFieldRef<Types extends SchemaTypes, T = unknown>
implements PothosSchemaTypes.InputFieldRef<Types, T>
{
kind = 'InputObject' as const;

fieldName?: string;
Expand Down
15 changes: 15 additions & 0 deletions packages/core/src/types/global/classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import type { ListRef as InternalListRef } from '../../refs/list';
import type { ObjectRef as InternalObjectRef } from '../../refs/object';
import type { ScalarRef as InternalScalarRef } from '../../refs/scalar';
import type { UnionRef as InternalUnionRef } from '../../refs/union';
import type { FieldRef as InternalFieldRef } from '../../refs/field';
import type { InputFieldRef as InternalInputFieldRef } from '../../refs/input-field';
import type { ArgumentRef as InternalArgumentRef } from '../../refs/arg';
import type { FieldKind } from '../builder-options';
import type { SchemaTypes } from '../schema-types';

Expand Down Expand Up @@ -68,5 +71,17 @@ declare global {
extends InternalUnionRef<Types, T, P> {}
export interface ListRef<Types extends SchemaTypes, T, P = T>
extends InternalListRef<Types, T, P> {}

export interface FieldRef<
Types extends SchemaTypes,
T = unknown,
Kind extends FieldKind = FieldKind,
> extends InternalFieldRef<Types, T, Kind> {}

export interface InputFieldRef<Types extends SchemaTypes, T>
extends InternalInputFieldRef<Types, T> {}

export interface ArgumentRef<Types extends SchemaTypes, T>
extends InternalArgumentRef<Types, T> {}
}
}
4 changes: 2 additions & 2 deletions packages/core/src/types/type-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ export type InputOrArgRef<
T,
Kind extends 'Arg' | 'InputObject',
> = Kind extends 'Arg'
? ArgumentRef<Types, T>
? PothosSchemaTypes.ArgumentRef<Types, T>
: Kind extends 'InputObject'
? InputFieldRef<Types, T>
? PothosSchemaTypes.InputFieldRef<Types, T>
: never;

export interface GenericFieldRef<T = unknown> {
Expand Down
12 changes: 10 additions & 2 deletions packages/plugin-add-graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,22 @@
},
"author": "Michael Hayes",
"license": "ISC",
"keywords": ["pothos", "graphql", "schema", "typescript", "add", "existing", "plugin"],
"keywords": [
"pothos",
"graphql",
"schema",
"typescript",
"add",
"existing",
"plugin"
],
"publishConfig": {
"access": "public",
"provenance": true
},
"peerDependencies": {
"@pothos/core": "*",
"graphql": ">=16.6.0"
"graphql": "^16.8.1"
},
"devDependencies": {
"@pothos/core": "workspace:*",
Expand Down
13 changes: 11 additions & 2 deletions packages/plugin-complexity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,23 @@
},
"author": "Michael Hayes",
"license": "ISC",
"keywords": ["pothos", "graphql", "schema", "plugin", "complexity", "depth", "query", "limit"],
"keywords": [
"pothos",
"graphql",
"schema",
"plugin",
"complexity",
"depth",
"query",
"limit"
],
"publishConfig": {
"access": "public",
"provenance": true
},
"peerDependencies": {
"@pothos/core": "*",
"graphql": ">=16.6.0"
"graphql": "^16.8.1"
},
"devDependencies": {
"@pothos/core": "workspace:*",
Expand Down
10 changes: 8 additions & 2 deletions packages/plugin-dataloader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,21 @@
"url": "git+https://github.com/hayes/pothos.git",
"directory": "packages/plugin-dataloader"
},
"keywords": ["pothos", "graphql", "schema", "typescript", "dataloader"],
"keywords": [
"pothos",
"graphql",
"schema",
"typescript",
"dataloader"
],
"publishConfig": {
"access": "public",
"provenance": true
},
"peerDependencies": {
"@pothos/core": "*",
"dataloader": "2",
"graphql": ">=16.6.0"
"graphql": "^16.8.1"
},
"devDependencies": {
"@pothos/core": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-directives/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"provenance": true
},
"peerDependencies": {
"graphql": ">=16.6.0"
"graphql": "^16.8.1"
},
"devDependencies": {
"@graphql-tools/utils": "^10.6.1",
Expand Down
11 changes: 9 additions & 2 deletions packages/plugin-drizzle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,21 @@
},
"author": "Michael Hayes",
"license": "ISC",
"keywords": ["pothos", "graphql", "schema", "typescript", "drizzle", "plugin"],
"keywords": [
"pothos",
"graphql",
"schema",
"typescript",
"drizzle",
"plugin"
],
"publishConfig": {
"access": "public",
"provenance": true
},
"peerDependencies": {
"@pothos/core": "*",
"graphql": ">=16.6.0"
"graphql": "^16.8.1"
},
"devDependencies": {
"@libsql/client": "^0.14.0",
Expand Down
14 changes: 11 additions & 3 deletions packages/plugin-errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,30 @@
},
"author": "Michael Hayes",
"license": "ISC",
"keywords": ["pothos", "graphql", "schema", "typescript", "error", "errors", "plugin"],
"keywords": [
"pothos",
"graphql",
"schema",
"typescript",
"error",
"errors",
"plugin"
],
"publishConfig": {
"access": "public",
"provenance": true
},
"peerDependencies": {
"@pothos/core": "*",
"graphql": ">=16.6.0"
"graphql": "^16.8.1"
},
"devDependencies": {
"@pothos/core": "workspace:*",
"@pothos/plugin-zod": "workspace:*",
"@pothos/test-utils": "workspace:*",
"graphql": "^16.8.1",
"graphql-tag": "^2.12.6",
"zod": "^3.23.8"
"zod": "^3.24.1"
},
"gitHead": "9dfe52f1975f41a111e01bf96a20033a914e2acc"
}
2 changes: 1 addition & 1 deletion packages/plugin-federation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"peerDependencies": {
"@apollo/subgraph": "^2.0.0",
"graphql": ">=16.6.0"
"graphql": "^16.8.1"
},
"devDependencies": {
"@apollo/gateway": "^2.9.3",
Expand Down
13 changes: 11 additions & 2 deletions packages/plugin-mocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,23 @@
},
"author": "Michael Hayes",
"license": "ISC",
"keywords": ["pothos", "graphql", "schema", "typescript", "mock", "mocks", "test", "stub"],
"keywords": [
"pothos",
"graphql",
"schema",
"typescript",
"mock",
"mocks",
"test",
"stub"
],
"publishConfig": {
"access": "public",
"provenance": true
},
"peerDependencies": {
"@pothos/core": "*",
"graphql": ">=16.6.0"
"graphql": "^16.8.1"
},
"devDependencies": {
"@pothos/core": "workspace:*",
Expand Down
12 changes: 9 additions & 3 deletions packages/plugin-prisma-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@
},
"author": "Michael Hayes",
"license": "ISC",
"keywords": ["pothos", "graphql", "schema", "typescript", "prisma"],
"keywords": [
"pothos",
"graphql",
"schema",
"typescript",
"prisma"
],
"publishConfig": {
"access": "public",
"provenance": true
Expand All @@ -48,7 +54,7 @@
"@pothos/core": "*",
"@pothos/plugin-prisma": "*",
"@prisma/client": "*",
"graphql": ">=16.6.0"
"graphql": "^16.8.1"
},
"devDependencies": {
"@pothos/core": "workspace:*",
Expand All @@ -63,6 +69,6 @@
"prisma": "^6.0.0",
"ts-node": "^10.9.2",
"typescript": "5.5.4",
"zod": "^3.23.8"
"zod": "^3.24.1"
}
}
2 changes: 1 addition & 1 deletion packages/plugin-prisma/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"peerDependencies": {
"@pothos/core": "*",
"@prisma/client": "*",
"graphql": ">=16.6.0",
"graphql": "^16.8.1",
"typescript": ">=4.7.2"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-relay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
"peerDependencies": {
"@pothos/core": "*",
"graphql": ">=16.6.0"
"graphql": "^16.8.1"
},
"devDependencies": {
"@pothos/core": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-scope-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"peerDependencies": {
"@pothos/core": "*",
"graphql": ">=16.6.0"
"graphql": "^16.8.1"
},
"devDependencies": {
"@pothos/core": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-simple-objects/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"peerDependencies": {
"@pothos/core": "*",
"graphql": ">=16.6.0"
"graphql": "^16.8.1"
},
"devDependencies": {
"@pothos/core": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-smart-subscriptions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"peerDependencies": {
"@pothos/core": "*",
"graphql": ">=16.6.0"
"graphql": "^16.8.1"
},
"devDependencies": {
"@pothos/core": "workspace:*",
Expand Down
Loading
Loading