wapplr-graphql
v1.0.72
Published
GraphQl extension for Wapplr
Downloads
39
Readme
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