Giter VIP home page Giter VIP logo

gramps-boilerplate's Introduction

gramps-boilerplate

๐Ÿš€ Basic starter code for a scalable, production-ready GraphQL server for Node.js.

Features

  • Scalable GraphQL Server: graphql-yoga based on Apollo Server & Express
  • GraphQL-native database: Includes GraphQL database binding to Graphcool (running on MySQL)
  • Out-of-the-box support for GraphQL Playground & Tracing
  • Simple data model โ€“ easy to adjust
  • Preconfigured graphql-config setup

Requirements

You need to have the following things installed:

  • Node 8+
  • Graphcool CLI: npm i -g graphcool@beta
  • GraphQL CLI: npm i -g graphql-cli
  • GraphQL Playground desktop app (optional): Download

Getting started

# Bootstrap GraphQL server in directory `my-app`, based on `node-basic` boilerplate
graphql create my-app --boilerplate node-basic

# Navigate to the new project
cd my-app

# Deploy the Graphcool database
graphcool deploy

# Start server (runs on http://localhost:4000)
yarn start

# Open Playground to explore GraphQL API
yarn playground
Alternative: Clone repo
# Clone the repo and navigate into project directory
git clone https://github.com/graphql-boilerplates/node-graphql-server.git
cd node-graphql-server/basic

# Deploy the Graphcool database
graphcool deploy

# Install node dependencies
yarn install

# Start server (runs on http://localhost:4000)
yarn start

# Open Playground to explore GraphQL API
yarn playground

Docs

Commands

  • yarn start starts GraphQL server
  • yarn playground opens the GraphQL Playground
  • yarn deploy deploys GraphQL server to now

Project structure

/ (root directory)

/database

  • database/datamodel.graphql contains the data model that you define for the project (written in SDL).
  • database/schema.generated.graphql defines the database schema. It contains the definition of the CRUD API for the types in your data model and is generated based on your datamodel.graphql. You should never edit this file manually, but introduce changes only by altering datamodel.graphql and run graphcool deploy.

/src

  • src/schema.graphql defines your application schema. It contains the GraphQL API that you want to expose to your client applications.
  • src/index.js is the entry point of your server, pulling everything together and starting the GraphQLServer from graphql-yoga.

Common questions

I'm getting a 'Schema could not be fetched.' error after deploying, what gives?

Access to the Graphcool API is secured by a secret. This also applies to the introspection query. Using the latest version of GraphQL Playground, the Authorization header should automatically be setup with a proper JWT signing the secret. If that's not the case, you can follow these steps to access your API:

  1. Visit http://jwtbuilder.jamiekurtz.com/
  2. Replace the Key at the bottom of the page with your secret from the graphcool.yml
  3. Click Create signed JWT and copy the obtained token
  4. Now, to access the schema, use the Authorization: Bearer <token> header, or in the GraphQL Playground set it as JSON:
    {
      "Authorization": "Bearer <token>"
    }
  5. Reload the schema in the Playground (the refresh-button is located right next to the URL of the server)

Note: Currently, no content of the signed JWT is verified by the database! This will be implemented according to this proposal at a later stage.

Contributing

Your feedback is very helpful, please share your opinion and thoughts! If you have any questions, join the #graphql-boilerplate channel on our Slack.

gramps-boilerplate's People

Contributors

kbrandwijk avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

gramps-boilerplate's Issues

Update boilerplate to only use gramps for delegation

Right now, the gramps schema is used as main schema for the server. This is not according to best practices. This boilerplate should be updated to include a public schema, and use the gramps datasource for delegation only. This can be done after the graphql-binding PR is merged, so a binding can be created based on the exposed GraphQLSchema from gramps().

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.