# @arquivei/codegen

> Codegen rules designed by Arquivei

Latest version **1.1.0** (published 2023-07-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @arquivei/codegen
pnpm add @arquivei/codegen
yarn add @arquivei/codegen
bun add @arquivei/codegen
```

## 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.1.0 |
| Published | 2023-07-17 |
| First published | 2022-04-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=14.0.0 |
| Dependencies | 6 |
| Unpacked size | 14.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Arquivei Servicos On Line Ltda |
| Maintainers | arquivei |
| Keywords | react, graphql, bff, typescript, codegen, config, arquivei |

## Links

- npm: https://www.npmjs.com/package/@arquivei/codegen
- Repository: https://github.com/arquivei/arquivei-tools
- Homepage: https://github.com/arquivei/arquivei-tools/tree/master/packages/codegen
- Issues: https://github.com/arquivei/arquivei-tools/issues
- npm.io page: https://npm.io/package/@arquivei/codegen

## Dependencies (6)

- [@graphql-codegen/cli](https://npm.io/package/@graphql-codegen/cli.md) 3.3.1
- [@graphql-codegen/typescript](https://npm.io/package/@graphql-codegen/typescript.md) 3.0.4
- [@graphql-codegen/typescript-resolvers](https://npm.io/package/@graphql-codegen/typescript-resolvers.md) 3.2.1
- [@graphql-codegen/typescript-operations](https://npm.io/package/@graphql-codegen/typescript-operations.md) 3.0.4
- [@graphql-codegen/typescript-react-apollo](https://npm.io/package/@graphql-codegen/typescript-react-apollo.md) 3.3.7
- [@graphql-codegen/typescript-apollo-client-helpers](https://npm.io/package/@graphql-codegen/typescript-apollo-client-helpers.md) 2.2.6

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2023-07-17
- 1.0.6 — 2022-07-15
- 1.0.5 — 2022-05-31
- 1.0.4 — 2022-05-06
- 1.0.3 — 2022-04-29
- 1.0.2 — 2022-04-19
- 1.0.1 — 2022-04-07

## README

# **@arquivei/codegen**

The @arquivei/codegen package aims to center all codegen rules from Typescript and GraphQL projects.

## **Usage**

Check below step by step to use this package:

:one: Install package in dev dependencies
```bash
❯ yarn add -D @arquivei/codegen
```

:two: Create `codegen.js` and configure according to your need

**Using in client-side:**
```js
const codegenConfig = require('@arquivei/codegen').default;

module.exports = codegenConfig({
  environment: 'client',
  options: {
    schema: "http://localhost:5000/graphql", // BFF url
    token: `Bearer TOKEN`, // non required, check if need
    config: {
      skipTypename: true,
      useTypeImports: true,
      documentMode: 'external',
    },
  },
});
```

**Using in BFF (server-side):**
```js
const codegenConfig = require('@arquivei/codegen').default;

module.exports = codegenConfig({
  environment: 'bff',
  options: {
    schema: './src/core/schema/*.graphql',
    config: {
      skipTypename: true,
      useTypeImports: true,
      contextType: '.#Context',
    },
  },
});
```

:three: Add script in your `package.json`
```json
"scripts": {
  "gen:types": "graphql-codegen",
}
```

:four: Run the script
```bash
❯ yarn gen:types
```
_OBS: if you're on client-side, be sure that BFF is up_

## **Properties**
| name | type | required | description |
|---|---|---|---|
| `environment` | `'client' \| 'bff'` | :heavy_check_mark: | Set your current environment. E.g: `frontend-saas` the value is `'client'` and `graphql-saas` is `bff`|
| `options.schema` | `string` | :heavy_check_mark: | Set schema location, glob files or URL  |
| `options.token` | `string` | :x: | If the server (BFF) has authentication |
| `options.documents` | `string` | :x: | [If you use plugins that generate code for the client-side](https://www.graphql-code-generator.com/docs/config-reference/documents-field) |
| `options.config` | `object` | :x: | Config codegen plugins |
| `options.outputFile` | `string` | :x: | File and path to sabe generated type files |
| `options.extraPlugins` | `string[]` | :x: | If you need add some extra plugins |

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