Giter Club home page Giter Club logo

parse-server-back4app-graphql-boilerplate's Introduction

this is a simple boilerplate to run GraphQL project as a cloud code on back4app. It is set-up to use typescript which also enables ES6 syntax (while it's transpiled to ES5 supported by back4app node)

minimum config required to set up GraphQL is as simple as:

provide a package.json located in cloud

{
  "dependencies": {
    "graphql": "0.13.1",
    "graphql-tools": "^3.0.1",
    "apollo-server-express": "1.3.6",
   }
}

and app.js also in cloud:

var fs = require("fs");
var path = require("path");

var apollo_server_express = require("apollo-server-express");
var graphql_tools = require("graphql-tools");
var bodyParser = require("body-parser");
var cors = require("cors");
var resolvers = {
    Query: {
        hello() { return "Hello world!"; }
    }
};

var schema = graphql_tools.makeExecutableSchema({
    typeDefs: fs.readFileSync(path.join(__dirname, './graphql/schema.graphql'), 'utf8'),
    resolvers: resolvers
});

app.use('/graphql', cors(), bodyParser.json(), apollo_server_express.graphqlExpress({ schema: schema }));
app.use('/graphiql', apollo_server_express.graphiqlExpress({
    // subscriptionsEndpoint: 'ws://seaas-test.back4app.io:80/subscriptions',
    endpointURL: '/graphql'
}));

together with schema.graphql in cloud/graphql/

schema {
    query: Query
}

type Query {
    hello: String!
}

these three files should be enough to have GraphQL set up.

To have make use of this boilerplate quickly you can run npm i, npm run build and then upload build/cloud folder using Dashboard -> Server Settings -> Cloud Code panel.

To make the process automated we may follow the https://docs.back4app.com/docs/integrations/command-line-interface/creating-a-parse-app/ with one important remark - as we need to deploy cloud code from build folder - we need to copy generated .parse.local and .parse.project to build folder so the npm run deploy can upload just the generated code to your app.

parse-server-back4app-graphql-boilerplate's People

Contributors

ciekawy avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.