Skip to content

Instantly share code, notes, and snippets.

@karimkawambwa
Created March 15, 2021 20:00
Show Gist options
  • Save karimkawambwa/dbbda7fe7442a8e6d3336889f69134f1 to your computer and use it in GitHub Desktop.
Save karimkawambwa/dbbda7fe7442a8e6d3336889f69134f1 to your computer and use it in GitHub Desktop.
Convert KeystoneJS v5 GraphQL operations into REST routes using sofa-api https://github.com/Urigo/sofa
useSofa({
schema,
basePath: "/rest",
context: ({ req }) => {
// console.log(req.url, req.originalUrl);
// console.log("Here");
},
execute: ({ source, variableValues }) => {
return keystone.executeGraphQL({
query: source,
variables: variableValues
});
},
onRoute(info) {
openApi.addRoute(info, {
basePath: "/rest"
});
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment