Skip to content

Latest commit

 

History

History
66 lines (53 loc) · 1.36 KB

README.md

File metadata and controls

66 lines (53 loc) · 1.36 KB

Wapplr-graphql

This package is the GraphQl extension for Wapplr.

//server.js
import wapplrGraphql, {createMiddleware as createWapplrGraphqlMiddleware} from "wapplr-graphql";
import wapplrServer from "wapplr";

const wapp = wapplrServer({config: {
        server: {
            disableUseDefaultMiddlewares: true,
            graphql: {
                route: "/graphql",
            }
        },
        globals: {
            WAPP: "yourBuildHash",
            ROOT: __dirname
        }
    }
});

wapplrGraphql({wapp});

const app = wapp.server.app; 

app.use([
    wapp.server.middlewares.wapp,
    wapp.server.middlewares.static,
    createWapplrGraphqlMiddleware({wapp}),
    ...Object.keys(wapp.server.middlewares).map(function (key){
        return (key === "wapp" || key === "static") ? 
            function next(req, res, next) { return next(); } : 
            wapp.server.middlewares[key];
    })
]);

wapp.server.listen();
//client.js
import wapplrGraphql from "wapplr-graphql";
import wapplrClient from "wapplr";

const wapp = wapplrClient({config: {
        client: {
            graphql: {
                route: "/graphql"
            }
        },
        globals: {
            WAPP: "yourBuildHash",
        }
    }
});

wapplrGraphql({wapp});

wapp.client.listen();

License

MIT