Code Monkey home page Code Monkey logo

node-graphql-prisma-server's Introduction

node-graphql-prisma-server

This is a boilerplate code for graphQL server with Prisma for binding with database.

Prerequisite

Node version 8.0.0 +

$ npm install -g prisma
$ npm install -g graphql-cli

you should have a knowledge of graphQL Schema Defination Language

Configuration

$ prisma deploy

The prisma deploy command starts an interactive process:

  • First select the Demo server from the options provided. When the browser opens, register with Prisma Cloud and go back to your terminal.
  • Then you need to select the region for your demo server. Once that’s done, you can just hit enter twice to use the suggested values for service and stage.

Note: Prisma is open-source. It is based on Docker which means you can deploy it to any cloud provider of your choice (such as Digital Ocean, AWS, Google Cloud, …). If you don’t want to deal with DevOps and the manual configuration of Docker, you can also use Prisma Cloud to easily spin up a private cluster to which you can deploy your services. Watch this short video to learn more about how that works.

it will print output url like following

https://eu1.prisma.sh/publica-graytracker-771/hackernews-node/dev

assign that url to endpoint variable in database/prisma.yml and src/index.js file

endpoint: https://eu1.prisma.sh/publica-graytracker-771/hackernews-node/dev

Note: If you ever lose the endpoint, you can get access to it again by running 'prisma info' in the terminal.

Explore Prisma Database

Prisma database is secure by default, to access it, we need to pass token. Let's generate it.

Open that url (https://eu1.prisma.sh/publica-graytracker-771/hackernews-node/dev) in your browser. Run following command to generate token to securaly access prisma database

$ prisma token

Then copy the token that was printed by the CLI and use it to configure an HTTP header in the Playground. You can do so by opening the HTTP HEADERS pane in the bottom-left corner of the Playground - notice that you need to replace the TOKEN placeholder with the actual token that was printed:

{
  "Authorization": "Bearer __TOKEN__"
}

Now you should be able to access Prisma database schema and you can also query it.

Usage

yarn install
node ./

In another terminal run following command to open playground

graphql playground

License

MIT

node-graphql-prisma-server's People

Contributors

mhdnp1234 avatar

Stargazers

Ryan Stimmler avatar

Watchers

James Cloos avatar  avatar

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.