npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@prisma/nexus

v0.0.1

Published

Scalable, strongly typed GraphQL schema development

Downloads

13

Readme

GraphQL Nexus

CircleCI npm version Join the community on Spectrum

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

GraphQL Nexus is independent from Prisma. To learn how it can best be combined with Prisma, check out the nexus-prisma plugin.

Overview

  • Code-first: Programmatically define your GraphQL types in JavaScript/TypeScript
  • Compatible with the GraphQL ecosystem: Nexus is based on graphql-js
  • Type-safe: Nexus enables auto-completion and error checks in your IDE (even for JS)
  • Generates SDL & TS definitions: SDL schema and typings are updated as you code

Examples

"Hello World" GraphQL server with graphql-yoga

import { queryType, stringArg, makeSchema } from "nexus";
import { GraphQLServer } from "graphql-yoga";

const Query = queryType({
  definition(t) {
    t.string("hello", {
      args: { name: stringArg({ nullable: true }) },
      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`);

All examples of GraphQL Nexus can be found in the /examples directory:

If you're interested in examples using the nexus-prisma plugin, check out the official prisma-examples repo:

Features

  • Expressive, declarative API for building schemas
  • 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
  • Assumes non-null by default, but makes this configurable on per-schema/per-type basis
  • 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
  • Lots of good examples to get you started and thorough API documentation
  • Full type-safety for free
  • Internal structure allows library authors to build more advanced abstractions
  • Independent from Prisma, but integrates nicely using the nexus-prisma plugin
  • Allows code re-use by creating higher level "functions" which wrap common fields

Documentation

You can find the docs for GraphQL Nexus here.

Install

GraphQL Nexus can be installed via the nexus package. It also requires graphql as a peer dependency:

npm install --save nexus graphql

or

yarn add nexus graphql

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:


License (MIT)

(c) 2018-2019 Tim Griesser

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.