# @gymlib/codegen-swap-directive

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

Latest version **1.0.5** (published 2022-03-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @gymlib/codegen-swap-directive
pnpm add @gymlib/codegen-swap-directive
yarn add @gymlib/codegen-swap-directive
bun add @gymlib/codegen-swap-directive
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2022-03-02 |
| First published | 2020-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 8.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | nmarien29@gmail.com |
| Maintainers | gymlib-user |

## Links

- npm: https://www.npmjs.com/package/@gymlib/codegen-swap-directive
- npm.io page: https://npm.io/package/@gymlib/codegen-swap-directive

## Dependencies (3)

- [graphql-compose](https://npm.io/package/graphql-compose.md) ~9.0.6
- [@graphql-codegen/typescript](https://npm.io/package/@graphql-codegen/typescript.md) 2.4.2
- [@graphql-codegen/plugin-helpers](https://npm.io/package/@graphql-codegen/plugin-helpers.md) 2.3.2

## Recent versions

- 1.0.5 (latest) — 2022-03-02
- 1.0.8 (v1.0.8) — 2023-10-02
- 1.0.7 (v1.0.7) — 2023-08-31
- 1.0.6 (v1.0.6) — 2023-08-31
- 1.0.4 — 2021-08-26
- 1.0.3 — 2020-08-25
- 1.0.2 — 2020-08-25
- 1.0.1 — 2020-07-02
- 1.0.0 — 2020-07-02

## README

# What is this?

This [graphql-codegen](https://github.com/dotansimha/graphql-code-generator) plugin is a wrapper around the existing [typescript](https://www.npmjs.com/package/ @graphql-codegen/typescript) plugin.

# How to use?

You need to add the following [directive](https://graphql.org/learn/queries/#directives)

```graphql
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.

# Example

```graphql
type SomeType {
  field1: SomeOtherType!
  field2: String! @swap(for: "SomeOtherType")
}
```

The output will look like this:

```typescript
type SomeOtherType = /*...*/;
type SomeType = {
  field1: SomeOtherType;
  field2: SomeOtherType;
}
```

---
_Source: https://npm.io/package/@gymlib/codegen-swap-directive · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
