GraphQL Nexus has reached version 1.0
Tags: graphql, node, typescript, webdev
Published: 2021-01-04 09:17:22


GraphQL Nexus is a library to build code-first GraphQL APIs that relies on Node.js and TypeScript. The code-first approach prioritizes the process of developing schema resolvers over the process of designing the schema. This approach puts resolvers in a leading position of a GraphQL project and making a schema shape dependent on resolvers (schema is implemented programmatically).

The key features provided by Nexus are:

- **Type-Safety** - type-definitions are being generated as you proceed with the development process & inferred in your code, providing you with auto-completion and error catching,
- **Data-Agnostic** - GraphQL Nexus is a declarative syntax layered on the top of the graphql-js means you can do with it all the same that you can accomplish with graphql-js or apollo-tools.

Having figured out all the types you need for your schema all you need to do is simply use `makeSchema` function to create the schema instance that would be used as the foundation for your GraphQL server.

## What's new in version 1.0 of GraphQL Nexus

Besides the fresh package name `nexus` which implicates the new way of importing things (use `nexus` instead of `@nexus/schema`)

```
import { makeSchema } from 'nexus' 
```
GraphQL Nexus 1.0 provides some important improvements and changes to the project among which we can find:
- **Changes to Nullability** - in previous versions of GraphQL Nexuls fields were marked by default as non-nullable, but version 1.0 requires to mark non-nullable fields explicitly.

![Redefined nullability in GraphQL Nexus 1.0](https://dev-to-uploads.s3.amazonaws.com/i/xjve2oj4396ookl8ry6q.png)

##### Source: [prisma.io](https://www.prisma.io/blog/announcing-the-release-of-nexus-schema-v1-b5eno5g08d0b)

- **Changes to the List API** - Nexus 1.0 introduces a new function for working with list types. The list function can be applied to inputs and outputs similar to how the nonNull and nullable functions are. The same chaining API for creating lists still remains, but the list function exists to help for situations where chaining is not ideal.
![Changes to the List API in GraphQL Nexus 1.0](https://dev-to-uploads.s3.amazonaws.com/i/gauswoewvv1geaze6d0c.png)

##### Source: [prisma.io](https://www.prisma.io/blog/announcing-the-release-of-nexus-schema-v1-b5eno5g08d0b)

- **Abstract Types** - version 1.0 offers API for implementing three approaches to abstract types (unions & interfaces) known from the official `graphql-js` package:
  - **Centralized Strategy (`resolveType`)** - discriminating union member types in a centralized way,
  - **Discriminant Model Field (DMF) Strategy (`__typename`)** - discriminating union member types in a modular way. 
  - **Modular Strategy (`isTypeOf`)** - discriminating union member types in a modular way. 
All along with the type safety.

- **Changes to Backing Types** - in version 1.0 `backing` and `root` types are globally referred to as `Source Types`.

Along with this spotlight changes version 1.0 introduced some smaller ones, not directly connected to the project codebase, but not less important i.e. [upgraded documentation](https://nexusjs.org/docs/), [guides](https://nexusjs.org/docs/guides/schema) and new codesandbox examples ([intro](https://codesandbox.io/s/nexus-example-introductory-graphql-api-pk0qr), [subscriptions](https://codesandbox.io/s/nexus-example-subscriptions-59kdb), [next.js](https://codesandbox.io/s/nexus-example-nextjs-b7055)).

---

## Want to speed up your GraphQL schema development?

*GraphQL Editor* is a supportive tool for both advanced GraphQL users as well as those taking their first steps with GraphQL APIs. Our all-in-one development environment for GraphQL will help you build, manage & deploy your GraphQL API much faster. **[Try GraphQL Editor for free!](https://graphqleditor.com)**


[![New features of GraphQL Editor gif](https://dev-to-uploads.s3.amazonaws.com/i/hz2iv2u1073dy9orexxf.gif)](https://graphqleditor.com/)