File tree Expand file tree Collapse file tree 2 files changed +25
-24
lines changed Expand file tree Collapse file tree 2 files changed +25
-24
lines changed Original file line number Diff line number Diff line change @@ -53,15 +53,14 @@ export default function({ data, url }) {
5353 url ,
5454 ( req , res ) =>
5555 new Promise ( resolve => {
56- handleRequest ( {
57- requestBody : req . body ( ) ,
58- respond ( status , headers , body ) {
59- res . status ( status ) ;
60- res . headers ( headers ) ;
61- res . body ( body ) ;
56+ handleRequest ( url , {
57+ body : req . body ( ) ,
58+ } ) . then ( response => {
59+ res . status ( response . status ) ;
60+ res . headers ( response . headers ) ;
61+ res . body ( response . body ) ;
6262
63- resolve ( res ) ;
64- } ,
63+ resolve ( res ) ;
6564 } ) ;
6665 } )
6766 ) ;
Original file line number Diff line number Diff line change @@ -42,8 +42,14 @@ import schemaBuilder from './schemaBuilder';
4242 */
4343export default function ( data ) {
4444 const schema = schemaBuilder ( data ) ;
45- return request => {
46- const query = JSON . parse ( request . requestBody ) ;
45+ return ( url , opts = { } ) => {
46+ let body = opts . body ;
47+
48+ if ( url . requestBody ) {
49+ body = url . requestBody ;
50+ }
51+
52+ const query = JSON . parse ( body ) ;
4753
4854 return graphql (
4955 schema ,
@@ -52,20 +58,16 @@ export default function(data) {
5258 undefined ,
5359 query . variables
5460 ) . then (
55- result => {
56- request . respond (
57- 200 ,
58- { 'Content-Type' : 'application/json' } ,
59- JSON . stringify ( result )
60- ) ;
61- } ,
62- error => {
63- request . respond (
64- 500 ,
65- { 'Content-Type' : 'application/json' } ,
66- JSON . stringify ( error )
67- ) ;
68- }
61+ result => ( {
62+ status : 200 ,
63+ headers : { 'Content-Type' : 'application/json' } ,
64+ body : JSON . stringify ( result ) ,
65+ } ) ,
66+ error => ( {
67+ status : 500 ,
68+ headers : { 'Content-Type' : 'application/json' } ,
69+ body : JSON . stringify ( error ) ,
70+ } )
6971 ) ;
7072 } ;
7173}
You can’t perform that action at this time.
0 commit comments