1.2.8 • Published 9 months ago

graphql-inherit-transformer v1.2.8

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

This is a custom GraphQL transformer for using with AWS AppSync and Amplify.

It allows you to add inheritance to types such that they can inherit all attributes from a parent type without the need for repetition of attributes

It also automatically converts any attributes for Query, Mutation and Subscription operation that are types instead of inputs

graphql-inherit-transformer

Pull requests are welcome! npm GitHub license

Installation

npm install --save graphql-inherit-transformer

How to use

Setup custom transformer

Edit amplify/backend/api/<YOUR_API>/transform.conf.json and append "graphql-inherit-transformer" to the transformers field.

"transformers": [
	"graphql-inherit-transformer"
]

Use @inherit directive

Add the @inherit(from: ["type1", "type2"]) directive to target types:

type Model {
	id: ID!
	createdAt: AWSTimestamp!
}

type UserModel @inherit(from: ["Model"]) {
	name: String!
}

After transformation results in:

type Model {
	id: ID!
	createdAt: AWSTimestamp!
}

type UserModel {
	name: String!
	id: ID!
	createdAt: AWSTimestamp!
}

Automatic input conversion

type Model {
	id: ID!
	createdAt: AWSTimestamp!
}

type Mutation {
	createModel(model: Model) Model
}

After transformation results in:

type Model {
	id: ID!
	createdAt: AWSTimestamp!
}

type ModelInput {
	id: ID!
	createdAt: AWSTimestamp!
}

type Mutation {
	createModel(model: ModelInput) Model
}

License

The MIT License

Credits

Created by James at Next Door Tutor Ltd

Used the graphql-ttl-transformer package by Florian Gyger Software as an example template to get started as I had no experience of custom graphQL transformers and had previously used this package.

1.2.8

9 months ago

1.2.7

9 months ago

1.2.6

10 months ago

1.2.5

10 months ago

1.2.4

10 months ago

1.2.3

10 months ago

1.2.2

10 months ago

1.2.1

10 months ago

1.2.0

10 months ago

1.1.5

10 months ago

1.1.4

10 months ago

1.1.3

10 months ago

1.1.2

10 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago