🌜
🌞
nexus

nexus

v1.3.0

Scalable, strongly typed GraphQL schema development

npm install nexus

README

Nexus

trunk npm version

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.

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
    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

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 directory:

Documentation

You can find the docs for Nexus here.

Migrate from SDL

If you've been following an SDL-first 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.

Release Notes

1.3.0
By Tim Griesser • Published on March 5, 2022
  • Added GraphQL v16 support #977
  • Added mergeSchema option, better graphql-js interop #983
1.1.0
By Jason Kuhrt • Published on June 23, 2021

Features

  • df7d137 field config with name (#938)
  • 2759c55 TO_NEXUS symbol for adding types via metaprogramming (#932)
  • 3a92760 Accept ReadonlyArray<T> for enum members (#916)
  • fbcfba3 connectionPlugin internal modifications (#811)
  • bb936cb add plugin support for inputObjectType (#799)
  • 666746c allow implementing interfaces in extendType (#774)
  • 4f3cef9 Add custom name options to Relay Connection plugin (#744)

Fixes

  • 81ec5c0 Allow meta types to be wrapped with null/list (#935)
  • 690abb7 correct edge node typing (#876)
  • 7ff557b sync should gen artifact logic with what docs say(#884)
  • 7f16b8b cast NexusNonNullDef to prevent union type complexity error (#846)
  • 27e35e5 reduce iteration in connections (#843)
  • aa283ad invoke correct fn on global extended connection/edge (#814)
  • 1f5b025 pass down source into extended connection fields (#812)
  • af73f66 Allow specifying overrides for builtin scalars (#795)

Improvements

  • 2b0708d refactor: TO_NEXUS -> NEXUS_TYPE / NEXUS_BUILD (#934)
  • 2e1c32b refactor: move makeSchema into separate file from builder (#927)
  • d2e586b refactor: make errors more readable (#887)
  • 74c93e2 refactor: add importsNotUsedAsValues: error to force import type (#872)

Docs

  • 571fa4d docs: Add link to GH Actions
  • a59273d docs: update the example of using a custom typing to GraphQL context value (#871)
  • 3f78131 docs: vanilla nexus migration from nexus-plugin-prisma (#838)
  • 46ad529 docs: add more information to field authorize plugin (#821)
  • 0b28c77 Docs: Correct an object's value in the tutorial (#808)
  • 0ce49b9 docs: adjust migration guide from nexus-plugin-prisma (#818)
  • 7f0dd11 docs: add migration guide for nexus-plugin-prisma (#817)
  • cb1e17e docs: Fix variable naming for express import (#802)
  • ebcdb29 Fix a typo in JSDoc example (#937)
  • 10ea65f add formatTypegen example (#930)
  • 031c772 Fix prisma link in examples README (#912)
  • 189a5be fix proper variable name (#904)
  • 70eda57 nexus nullability defaults (#900)
  • 5844b7f update API link to Prisma object modeling (#890)
  • 7b84cd6 broken link (#881)
  • 3c18d6c Nexus nullability defaults to that everything is null by default
  • 9a3915e updated prisma references (#874)
  • ce1bd8c fix typo in abstract types documentation (#873)
  • 5056129 removed databaseUrl in final code sample testing (#863)
  • c89c72b Change --transpileOnly to --transpile-only from star-wars example (#859)
  • 3050c3b Updated getting started tutorial (#852)
  • 291e86a fix broken link in 070-make-schema.mdx (#851)
  • 4625a13 update 010-object-type.mdx (#847)
  • 8827f28 Update 06-chapter-5-persisting-data-via-prisma.mdx (#848)
  • d220d31 deprecated nexus/testing module #833 (#840)
  • e3b414d Fix Docs 061-list-nonNull.mdx (#837)
  • 43f1da2 Updated tutorial docs (chapter 5 persisting-data-via-prisma) to fix cli install instructions (#834)
  • bfdd420 adoption guide link to with-prisma example fix (#794)
  • de04999 use db push (#793)
  • 025d82e Update 010-object-type.mdx (#791)
  • b327841 update migrate commands (#792)
  • 0788e86 update context type config to new api
  • 1c7b9b1 Change backingTypesMap to mapping (#782)
  • 55bca2d fix code example (#781)
  • cb22957 remove tutorial intro wip warning
  • 217779b remove outdated prisma plugin config docs (#777)
  • fe1dd14 Small changes to docs (#776)
  • 3f27f9e example MIT license
  • 91c775e update example deps
  • d996212 remove obsolete prisma plugin settings type
  • a782944 remove obsolete prisma plugin example
  • b69b30f remove todo auth chapter
  • ea3f994 fix framework migration package ambiguity
  • 9afc643 add docs for common field config of prisma plugin (#735)
  • 5116a18 use sourceType in locally configure Source Types (#769)
  • 2141a77 Update 04-chapter-3-adding-mutations-to-your-api.mdx (#751)
  • 8c324a6 Add import db in diff to match code (#755)
  • bcc0cee update tutorial to use new prisma migrate preview (#752)
  • 1a3c3c5 fix examples for abstract types to work with Typescript (#743)
  • c4b35b3 fix api usage (#765)
  • fcc66eb fix bad context import documention (#756)
  • 2e76a4f fix docs overview link to repo examples (#763)
  • c1aa267 Update 07-chapter-6-testing-with-prisma.mdx (#766)
  • bef7786 use new prisma migrate command (#732)
  • c2acf9b fix links in prisma plugin index page
  • 2b44900 better prisma plugin index page
  • 0ed742a fix URLs point to git repo trunk
  • 5c4d6de update git repo URLs
  • 4c52f59 update package git repo url
  • bd9ea3f try fixing image URLs
  • 1ebae9f update nexus ver in examples
  • 6b5fcce rename Nexus Schema to Nexus (#700)
  • 16ac615 chore(docs) Fix Broken Link in Tutorial Chapter 2 (#877)
  • 31a6137 Fix graphql docs link for interfaces (#913)
  • cfff794 updated test script and server start (#882)
  • 3f05c1d Resolve bullet indentation issue (#879)

Chores

  • 06cd0a0 yaml style
  • 5d23123 tsconfig should exclude docs
1.0.0
By Jason Kuhrt • Published on December 14, 2020

BREAKING CHANGES

rename package to nexus

#699 → 80ad531

You will now need to install Nexus Schema from the npm package nexus instead of @nexus/schema.

forbid null for descriptions

0a43cbc

It is no longer permitted to pass null to description of enum, objects, args, input objects, interfaces, unions. Now you must pass either a string or nothing.

remove backward compatible code and warnings

#730 → 78b8b08

  • Legacy resolveType is no longer part of the API
  • Legacy scalar shorthands are no longer supported
  • declarativeWrappingPlugin is no longer enabled by default
  • ScalarInputFieldConfig type is removed

Rename typegenAutoConfig and rootTyping

#723 → d66e8f1

Make contextType independent of source types

642be8b


Features

  • 78b8b08 (breaking) remove backward compatible code and warnings (#730)
  • d66e8f1 (breaking) rename typegenAutoConfig and rootTyping (#723)
  • 642be8b (breaking) make contextType independent of source types
  • dc1e21b pass connection args to field extensions (#710)
  • 96368ab allow arbitrary extensions on nexus types (#684)
  • 0cff220 Don't force async if connection resolvers are sync (#707)
  • 9d0f4f4 add .asArg for enum, fix default typings (#708)
  • cf5b269 support [email protected]^14.5 (#677)
  • 71ea266 allow promise to be returned from pageInfoFromNodes
  • bb13600 add requireResolver: false
  • af7c06c connection can accept non-String cursor

Fixes

  • 242046c subscriptionField overload for builder api access (#694)
  • 6220d85 proper typings for edge extension
  • 927d4b8 export connection plugin args
  • 8d14709 custom edge fields not resolved

Improvements

  • 80ad531 (breaking) improve: rename package to nexus (#699)
  • 5377df5 docs: cover abstract type funcs with jsdoc
  • 3531a31 docs: cover root types with jsdoc
  • 57ca56f docs: cover arguments related things with jsdoc (#726)
  • 0a43cbc (breaking) improve: forbid null for descriptions
  • 7dbb4ac docs: cover isTypeOf and extension with jsdoc (#720)
  • 405ee53 docs: cover resolve method with jsdoc
  • 08ce751 docs: add jsdoc for type prop on field config
  • 6f51434 docs: cover the output type builder api with jsdoc (#715)
  • e05a50e docs: cover extendType with jsdocs
  • 2c8102b docs: cover objectType with jsdocs (#703)

Docs

  • 81f2e37 docs: move source type section into its own guide (#711)
  • 0191f69 docs: add sticky table of content
  • 1da85cf marker outside of li, fix positioning (#719)
  • c6a8399 add feedback loop and code re-use to Why Nexus (#725)
  • fa3fd96 update "Why Nexus" (#712)
  • 02bff7d use plain JS objects for storing the context (#718)
  • c2a3ef9 update tutorial testing chapter (#709)
  • b5e3335 own guide for nullability
  • c16f6c6 fix typo
  • 96b31d3 fix typo
  • a9ca189 fix many things in the tutorial
  • 947b04a fix common to install test deps in tutorial
  • df3819e fix errors in next.js guide
  • e3253ab add nexus next.js adoption guide (#691)
  • 27d95d8 code sandbox for subscriptions
  • abed6e0 update playground link to codesandbox
  • 1e4fd3c fix nullability yaml frontmatter

Chores

  • 8b3e88c add support for interfaces implementing interfaces to sdlConverter (#713)
  • ea989d5 SDLConverter fixes (#717)
  • 439864a Prettier on the codebase for JSDoc formatting (#706)
  • fae8aeb bump jest testTimeout, seems to flake on unionTooComplexToRepresent
0.12.0-rc.7
By Tim Griesser • Published on January 23, 2020

Adds connectionPlugin for relay style pagination:

See: https://nexus.js.org/docs/plugin-connection and https://github.com/prisma-labs/nexus/pull/324 for more info

0.12.0-rc.5
By Tim Griesser • Published on November 20, 2019
  • feat: add customPrintSchemaFn to makeSchema config
0.12.0-rc.3
By Tim Griesser • Published on November 4, 2019
  • fix: bug in nullability check plugin

General

License
MIT
Typescript Types
Built-in
Tree-shakeable
Yes

Popularity

GitHub Stargazers
3,108
Community Interest
2,908
Number of Forks
277

Maintenance

Commits
10/219/22010
Last Commit
Open Issues
228
Closed Issues
393
Open Pull Requests
13
Closed Pull Requests
61

Versions

Versions Released
10/219/2206
Latest Version Released
Mar 5, 2022
Current Tags
latest1.3.0
beta0.12.0-rc
next1.4.0-next.11
pr2360.0.0-pr.236.0c37c30
pr2750.0.0-pr.275.004e62d
pr.5670.0.0-pr.567.3.8909f4a
pr.6570.0.0-pr.657.2.1659f86
pr.6990.0.0-pr.699.1.5377df5
pr.7400.0.0-pr.740.6.a429235
pr.7880.0.0-pr.788.3.8dd7202
pr.8300.0.0-pr.830.2.c3fd637
pr.8590.0.0-pr.859.1.8cce03f
pr.8700.0.0-pr.870.2.f69279d
pr.9380.0.0-pr.938.2.11866c9
pr.10570.0.0-pr.1057.2.ddd54d9
pr.12110.0.0-pr.1211.1.01ba274
pr.12230.0.0-pr.1223.1.785898d

Contributors

tgriesser
tgriesser
Commits: 318
jasonkuhrt
jasonkuhrt
Commits: 116
Weakky
Weakky
Commits: 28
nikolasburk
nikolasburk
Commits: 14
janpio
janpio
Commits: 10
ahmedosama5200
ahmedosama5200
Commits: 6
ruheni
ruheni
Commits: 5
chenkie
chenkie
Commits: 4
nilubava
nilubava
Commits: 4
shreyas44
shreyas44
Commits: 3
johnnyoshika
johnnyoshika
Commits: 3
valentinpalkovic
valentinpalkovic
Commits: 3
santialbo
santialbo
Commits: 3
Sytten
Sytten
Commits: 3
estrada9166
estrada9166
Commits: 2