MCPcopy
hub / github.com/graphql-nexus/nexus

github.com/graphql-nexus/nexus @v1.3.0 sqlite

repository ↗ · DeepWiki ↗ · release v1.3.0 ↗
1,436 symbols 3,395 edges 299 files 44 documented · 3%
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.

Extension points exported contracts — how you extend this code

NexusExtendTypeConfig (Interface)
(no doc) [5 implementers]
src/definitions/extendType.ts
SourceTypeModule (Interface)
(no doc)
src/typegenAutoConfig.ts
BaseExtensionConfig (Interface)
(no doc)
src/dynamicMethod.ts
PluginConfig (Interface)
(no doc)
src/plugin.ts
NexusSchemaExtensionConfig (Interface)
(no doc)
src/extensions.ts
ConfiguredTypegen (Interface)
(no doc)
src/builder.ts
RebuildConfig (Interface)
(no doc)
src/rebuildType.ts
DynamicOutputPropertyConfig (Interface)
(no doc)
src/dynamicProperty.ts

Core symbols most depended-on inside this repo

objectType
called by 202
src/definitions/objectType.ts
field
called by 175
src/definitions/subscriptionType.ts
string
called by 123
src/definitions/subscriptionType.ts
makeSchema
called by 103
src/makeSchema.ts
id
called by 66
src/definitions/subscriptionType.ts
nonNull
called by 56
src/definitions/nonNull.ts
queryField
called by 55
src/definitions/queryField.ts
implements
called by 50
src/definitions/objectType.ts

Shape

Interface 529
Function 514
Method 301
Class 86
Enum 6

Languages

TypeScript100%

Modules by API surface

src/typegenPrinter.ts67 symbols
src/builder.ts64 symbols
src/utils.ts60 symbols
src/definitions/definitionBlocks.ts43 symbols
src/plugins/connectionPlugin.ts35 symbols
examples/ghost/src/generated/ghost-db-types.ts35 symbols
examples/kitchen-sink/src/kitchen-sink.gen.ts33 symbols
src/sdlConverter.ts30 symbols
src/definitions/wrapping.ts30 symbols
tests/integrations/kitchenSink/__typegen.ts27 symbols
tests/definitions/nexusMeta.spec.ts25 symbols
examples/ghost/src/generated/ghost-nexus.ts22 symbols

Used by 2 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

@mdx-js/loader0.20.3 · 1×
@mdx-js/mdx1.5.5 · 1×
@mdx-js/react1.5.5 · 1×
@mdx-js/tag0.20.3 · 1×
@now/node1.0.1 · 1×
@philpl/buble0.19.7 · 1×
@prisma/cli2.0.0-beta.2 · 1×
@prisma/client2.0.0-beta.2 · 1×
@reach/router1.3.3 · 1×
@tgriesser/schemats6.1.0 · 1×
@types/dedent0.7.0 · 1×
@types/express4.16.1 · 1×

For agents

$ claude mcp add nexus \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact