# @gql2ts/language-typescript

> typescript defaults

Latest version **1.9.0** (published 2018-09-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install @gql2ts/language-typescript
pnpm add @gql2ts/language-typescript
yarn add @gql2ts/language-typescript
bun add @gql2ts/language-typescript
```

## 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.9.0 |
| Published | 2018-09-10 |
| First published | 2017-04-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 12.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 27 |
| Author | Brett Jurgens |
| Maintainers | brettjurgens |
| Keywords | gql2ts, graphql, typescript |

## Links

- npm: https://www.npmjs.com/package/@gql2ts/language-typescript
- Repository: https://github.com/avantcredit/gql2ts
- Homepage: https://github.com/avantcredit/gql2ts#readme
- Issues: https://github.com/avantcredit/gql2ts/issues
- npm.io page: https://npm.io/package/@gql2ts/language-typescript

## Dependencies (2)

- [humps](https://npm.io/package/humps.md) ^2.0.0
- [@gql2ts/util](https://npm.io/package/@gql2ts/util.md) ^1.9.0

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 1.9.0 (latest) — 2018-09-10
- 2.0.0-0 (next) — 2018-10-17
- 1.9.0-alpha.5ddac749 (canary) — 2018-06-06
- 1.11.0-alpha.95b0b3b3 — 2018-10-17
- 1.11.0-alpha.4807d000 — 2018-10-17
- 1.11.0-alpha.b353a569 — 2018-10-16
- 1.11.0-alpha.905b1daf — 2018-10-16
- 1.11.0-alpha.aea052fd — 2018-10-16
- 1.11.0-alpha.79abe854 — 2018-10-15
- 1.11.0-alpha.8b444a63 — 2018-10-15
- 1.11.0-alpha.12ee5e9b — 2018-10-15
- 1.9.0-alpha.ad6013c2 — 2018-08-17
- 1.8.2 — 2018-08-02
- 1.8.2-0 — 2018-08-01
- 1.8.1 — 2018-07-23
- … 47 more at https://npm.io/package/@gql2ts/language-typescript/versions

## README

# GQL2TS

[![Greenkeeper badge](https://badges.greenkeeper.io/avantcredit/gql2ts.svg)](https://greenkeeper.io/)
[![npm version](https://badge.fury.io/js/gql2ts.svg)](https://badge.fury.io/js/gql2ts)
[![TravisCI Build Status](https://travis-ci.org/avantcredit/gql2ts.svg?branch=master)](https://travis-ci.org/avantcredit/gql2ts)
[![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/kfa00svxkiqfb4yh/branch/master?svg=true)](https://ci.appveyor.com/project/brettjurgens/gql2ts/branch/master)
[![Coveralls Coverage](https://coveralls.io/repos/github/avantcredit/gql2ts/badge.svg)](https://coveralls.io/github/avantcredit/gql2ts)
[![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)

Generate TypeScript and Flow type interfaces from GraphQL types and query definitions.

```shell
# for CLI
npm install -g gql2ts

# for programmatic use
npm install @gql2ts/from-query
npm install @gql2ts/from-schema
```

## Structure

This project is a lerna mono repo, consisting of multiple packages.

## Goals and usage

This project can either:

- Take a type schema to generate TS interfaces
- Take a type schema & query and generate TS interfaces

### Generate from type schema

Pass a GraphQL `type` schema to generate a TypeScript interface:

Input:

```graphql
type Query {
  thing: String!
  anotherThing: Boolean!
}
```

Output:

```ts
interface IQuery {
  thing: string;
  anotherThing: boolean;
}
```

## Generate from type schema and query

Pass a `type` and `query` to generate a TypeScript interface:

Input:

```graphql
type Query {
  thing: String!
  anotherThing: Boolean!
}
```

```graphql
query GetThing {
  thing
}
```

Output

```ts
interface GetThing {
  thing: string;
}
```

## Language output

Note that `flow` and `typescript` generator outputs are supported via separate packages:

- `language-flow` - defaults for running `gql2ts` with Flow as your target
- `language-typescript` - defaults for running `gql2ts` with Typescript as your target

### Fine control

If you look into the `index.ts` of either `from-query` or `from-schema` packages:

```js
import {
  DEFAULT_TYPE_MAP,
  DEFAULT_OPTIONS,
} from '@gql2ts/language-typescript';
```

This can be replaced with mathing `flow` configuration objects:

```js
import {
  DEFAULT_TYPE_MAP,
  DEFAULT_OPTIONS,
} from '@gql2ts/language-flow';
```

Note: Flow output support has yet to be packaged and made available for the CLI.

## Packages

See the `packages` directory for package Readmes.

```sh
packages/cli                  # gql2ts CLI
packages/from-query           # @gql2ts/from-query
packages/from-schema          # @gql2ts/from-schema
packages/language-flow        # @gql2ts/language-flow
packages/language-typescript  # @gql2ts/language-typescript
packages/loader               # @gql2ts/loader
packages/types                # @gql2ts/types
packages/util                 # @gql2ts/util
```

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