# nexus

> Scalable, strongly typed GraphQL schema development

Latest version **1.3.0** (published 2022-03-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install nexus
pnpm add nexus
yarn add nexus
bun add nexus
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2022-03-05 |
| First published | 2011-11-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 2.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3428 |
| Author | Tim Griesser |
| Maintainers | tgriesser, schickling, jasonkuhrt, weakky |
| Keywords | graphql, schema, types, typescript |

## Links

- npm: https://www.npmjs.com/package/nexus
- Repository: https://github.com/graphql-nexus/nexus
- Homepage: https://nexusjs.org/
- npm.io page: https://npm.io/package/nexus

## Dependencies (2)

- [tslib](https://npm.io/package/tslib.md) ^2.0.3
- [iterall](https://npm.io/package/iterall.md) ^1.3.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.3.0 (latest) — 2022-03-05
- 1.4.0-next.13 (next) — 2023-03-16
- 0.0.0-pr.938.2.11866c9 (pr.938) — 2021-06-23
- 0.0.0-pr.699.1.5377df5 (pr.699) — 2020-12-14
- 0.0.0-pr.1223.1.785898d (pr.1223) — 2020-07-19
- 0.0.0-pr.1211.1.01ba274 (pr.1211) — 2020-07-13
- 0.0.0-pr.1057.2.ddd54d9 (pr.1057) — 2020-06-17
- 0.0.0-pr.859.1.8cce03f (pr.859) — 2020-05-23
- 0.0.0-pr.870.2.f69279d (pr.870) — 2020-05-15
- 0.0.0-pr.830.2.c3fd637 (pr.830) — 2020-05-08
- 0.0.0-pr.788.3.8dd7202 (pr.788) — 2020-05-05
- 0.0.0-pr.740.6.a429235 (pr.740) — 2020-04-27
- 0.0.0-pr.657.2.1659f86 (pr.657) — 2020-04-14
- 0.0.0-pr.567.3.8909f4a (pr.567) — 2020-03-31
- 0.12.0-rc (beta) — 2019-10-31
- … 380 more at https://npm.io/package/nexus/versions

## README

# Nexus

[![trunk](https://github.com/graphql-nexus/nexus/workflows/trunk/badge.svg)](https://github.com/graphql-nexus/nexus/actions/workflows/trunk.yml)
[![npm version](https://badge.fury.io/js/%40nexus%2Fschema.svg)](https://badge.fury.io/js/%40nexus%2Fschema)

Declarative, code-first and strongly typed GraphQL schema construction for TypeScript & JavaScript.

## Installation

```
npm install nexus graphql
```

Note you must also add `graphql`. Nexus pins to it as a [peer dependency](https://nodejs.org/en/blog/npm/peer-dependencies/).

## Features

- **Expressive, declarative API for building schemas**
- **Full type-safety for free**
- **Powerful plugin system**
- **No need to re-declare interface fields per-object**
- **Optionally possible to reference types by name (with autocomplete)**  
  Rather than needing to import every single piece of the schema
- **Interoperable with vanilla `graphql-js` types, and it's _just_ a [`GraphQLSchema`](https://graphql.org/graphql-js/type/#graphqlschema)**  
  So it fits in just fine with existing community solutions of `apollo-server`, `graphql-middleware`, etc.
- **Inline function resolvers**  
  For when you need to do simple field aliasing
- **Auto-generated graphql SDL schema**  
  Great for when seeing how any code changes affected the schema
- **DRY-up schema design**  
  Create higher level "functions" which wrap common fields

## Example

```ts
import { queryType, stringArg, makeSchema } from 'nexus'
import { GraphQLServer } from 'graphql-yoga'

const Query = queryType({
  definition(t) {
    t.string('hello', {
      args: { name: stringArg() },
      resolve: (parent, { name }) => `Hello ${name || 'World'}!`,
    })
  },
})

const schema = makeSchema({
  types: [Query],
  outputs: {
    schema: __dirname + '/generated/schema.graphql',
    typegen: __dirname + '/generated/typings.ts',
  },
})

const server = new GraphQLServer({
  schema,
})

server.start(() => `Server is running on http://localhost:4000`)
```

More examples can be found in the [`/examples`](./examples) directory:

- [githunt-api](./examples/githunt-api)
- [ts-ast-reader](./examples/ts-ast-reader)
- [apollo-fullstack](./examples/apollo-fullstack)
- [star-wars](./examples/star-wars)
- [kitchen-sink](./examples/kitchen-sink)

## Documentation

You can find the docs for Nexus [here](http://nexusjs.org/).

## Migrate from SDL

If you've been following an [SDL-first](https://www.prisma.io/blog/the-problems-of-schema-first-graphql-development-x1mn4cb0tyl3/) approach to build your GraphQL server and want to see what your code looks like when written with GraphQL Nexus, you can use the [**SDL converter**](https://nexus.js.org/converter).

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