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

graphql-fullstack

v0.0.8

Published

Experimental GraphQL-oriented web framework.

Downloads

13

Readme

npm version

graphql-fullstack

Experimental GraphQL-oriented web framework.

Inspired by https://github.com/nuwave/lighthouse

Install

npm install --save graphql-fullstack

Or if you use Yarn:

yarn add graphql-fullstack

Getting Started

First, write your schema and resolver:

schema.graphql

type Query {
  hello: String @field(resolver: "hello")
}

resolvers/hello.js

module.exports = () => 'world'

Then run GraphQL server:

npx graphql-fullstack serve --schema schema.graphql
# => running on http://localhost:5252

Now you can request GraphQL:

curl -XPOST localhost:5252/graphql -d query='query Hello { hello }'

returns

{
  "data": {
    "hello": "world"
  }
}

Directives

GraphQL-Fullstack will have various kind of directives.

@create

Create given model type from input variables.

type User {
  id: String!
  name: String
}

input UserInput {
  name: String
}

type Mutation {
  createUser(input: UserInput!): User @create(type: User)
}

@all

Read all data of given model type.

type User {
  id: String!
  name: String
}

type Query {
  users: [User] @all(type: User)
}

@field

Manually resolve a field. resolver argument is the file name of the resolver. It defaults to ./resolvers, but you can change it by config file (see below).

type User {
  id: String!
  name: String
}

type Query {
  user: User @field(resolver: 'UserResolver')
}

Config

You can change the path of your project.

Create graphql.config.js file and run npx graphql-fullstack with -c or --config option.

const { resolve } = require('path')

module.exports = {
  basePath: resolve(__dirname),

  // Resolver search paths.
  resolvers: [
    // By default, $PWD/resolvers is set, but you can set other resolver paths.
    resolve(__dirname, 'path/to/your/resolvers'),
  ],
}
npx graphql-fullstack -c graphql.config.js

CRUD example

type User {
  id: String!
  name: String
}

input UserInput {
  name: String
}

type Query {
  users: [User] @all(type: User)
}

type Mutation {
  createUser(input: UserInput!): User @create(type: User)
}

Roadmap

  • [x] Basic GraphQL features
    • [x] Resolver
    • [x] Input type
  • [x] Use MongoDB to store relational data [opinionated]
    • [ ] create
    • [ ] read
      • all
      • find
      • where
    • [ ] update
    • [ ] delete
  • [ ] Middleware