Created
March 15, 2021 20:00
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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