graphql-type-to-input-transformer
v1.0.0
Published
Allows you to create an input from a type in your GraphQL schema using the @input directive.
Downloads
3
Maintainers
Readme
This is a custom GraphQL transformer for using with AWS AppSync and Amplify.
It allows you to automatically create an input for a type on the schema without having to recreate the definition as an input
graphql-type-to-input-transformer
Installation
npm install --save graphql-type-to-input-transformer
How to use
Setup custom transformer
Edit amplify/backend/api/<YOUR_API>/transform.conf.json
and append "graphql-type-to-input-transformer"
to the transformers
field.
"transformers": [
"graphql-type-to-input-transformer"
]
Use @input directive
Add the @input
directive to target types:
type Model @input{
id: ID!
createdAt: AWSTimestamp!
}
After transformation results in:
type Model {
id: ID!
createdAt: AWSTimestamp!
}
input ModelInput {
id: ID!
createdAt: AWSTimestamp!
}
The directive will create a new input with the same name as the model but with 'Input' appended to it. It will error if you already have any type defined with that name.
License
The MIT License
Credits
Created by James at Next Door Tutor Ltd