Socket
Book a DemoInstallSign in
Socket

graphql-fullstack

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-fullstack

Experimental GraphQL-oriented web framework.

0.0.8
latest
npmnpm
Version published
Weekly downloads
8
700%
Maintainers
1
Weekly downloads
 
Created
Source

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

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

FAQs

Package last updated on 19 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.