-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
782 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "@giraphql/plugin-validation", | ||
"version": "1.0.0", | ||
"description": "A GiraphQL plugin for adding argument validation", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "Michael Hayes", | ||
"license": "ISC", | ||
"keywords": [ | ||
"giraphql", | ||
"graphql", | ||
"schema", | ||
"typescript", | ||
"zod", | ||
"validation", | ||
"validate" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"peerDependencies": { | ||
"@giraphql/core": "^0.20.3", | ||
"graphql": ">=15.1.0", | ||
"zod": "^1.11.11" | ||
}, | ||
"devDependencies": { | ||
"apollo-server": "^2.21.2", | ||
"graphql-tag": "^2.11.0", | ||
"zod": "^1.11.11" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import { | ||
FieldNullability, | ||
FieldRequiredness, | ||
InputFieldMap, | ||
InputShapeFromFields, | ||
InputShapeFromTypeParam, | ||
InputType, | ||
SchemaTypes, | ||
TypeParam, | ||
} from '@giraphql/core'; | ||
import { ValidationOptions } from './types'; | ||
import { GiraphQLValidationPlugin } from '.'; | ||
|
||
declare global { | ||
export namespace GiraphQLSchemaTypes { | ||
export interface Plugins<Types extends SchemaTypes> { | ||
validation: GiraphQLValidationPlugin<Types>; | ||
} | ||
|
||
export interface FieldOptions< | ||
Types extends SchemaTypes, | ||
ParentShape, | ||
Type extends TypeParam<Types>, | ||
Nullable extends FieldNullability<Type>, | ||
Args extends InputFieldMap, | ||
ResolveShape, | ||
ResolveReturnShape | ||
> { | ||
validate?: ValidationOptions<InputShapeFromFields<Args>>; | ||
} | ||
|
||
export interface InputFieldOptions< | ||
Types extends SchemaTypes = SchemaTypes, | ||
Type extends InputType<Types> | [InputType<Types>] = InputType<Types> | [InputType<Types>], | ||
Req extends FieldRequiredness<Type> = FieldRequiredness<Type> | ||
> { | ||
validate?: ValidationOptions<InputShapeFromTypeParam<Types, Type, true>>; | ||
} | ||
} | ||
} |
Oops, something went wrong.