GraphQL SDL inputs
Generate all Prisma inputs type for GraphQL
Install
npm i @paljs/plugins
use
import { mergeTypeDefs } from '@graphql-tools/merge';
import { sdlInputs } from '@paljs/plugins';
export default mergeTypeDefs([sdlInputs(), ...customTypes]);
api
sdlInputs
function using a Prisma generated files dmmf
to create DocumentNode
have all your inputs type.
takes one arg: you can pass object of options.
example
interface OptionsType {
// if you use a custom generated files path you need to import dmmf from this path and send to our function through this option.
dmmf?: DMMF.Document;
// by default when we create update inputs you will set data like {username: {set: "Ahmed"}} by making this option true you will be able to use it like {username: "Ahmed"} without set.
// but you will also lose these options for number fields
// increment: x: Adds x to the current value
// decrement: x: Subtracts x from the current value
// multiply: x: Multiplies the current value by x
// divide: x: Divides the current value by x
// set: x: Sets the value to x (equivalent to data: { age: 18 })
doNotUseFieldUpdateOperationsInput?: boolean;
}
// example
import { dmmf } from './prismaCustomPath';
import { mergeTypeDefs } from '@graphql-tools/merge';
import { sdlInputs } from '@paljs/plugins';
export default mergeTypeDefs([sdlInputs({ dmmf }), ...customTypes]);