@graphql-codegen plugin to add a @swap directive to the existing typescript plugin

Downloads in past


1.0.57 months ago2 years agoMinified + gzip package size for @gymlib/codegen-swap-directive in KB


What is this?
This graphql-codegen plugin is a wrapper around the existing typescript plugin.
How to use?
You need to add the following directive
directive @swap(for: String) on FIELD_DEFINITION

on your SDL definitions.
Then you will have to add the plugin as a replacement for the typescript plugin.
type SomeType {
  field1: SomeOtherType!
  field2: String! @swap(for: "SomeOtherType")

The output will look like this:
type SomeOtherType = /*...*/;
type SomeType = {
  field1: SomeOtherType;
  field2: SomeOtherType;