You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue
Unless I add the config option of formatResponse if I encounter a typeError in my internal server logic I will get back a statusCode of 200. When I add formatResponse a 500 will surface as expected.
Reproduce Error
Deliberate TypeError, statusCode of 200 is sent back to Client
server.register({register: graphqlHapi,options : {path : '/graphql',graphqlOptions: {schema : schema,graphiql : true,rootValue: server.methods,context: {name: 'Samuel Joli'}}}});constfetchDataFunction={}fetchDataFunction.get=function(){/* Fetch some data */}// Deliberate incorrect namespacingconstquery=newgraphql.GraphQLObjectType({name : 'Query',fields: {storefront: {type: Storefront,args: {id: {type: graphql.GraphQLString}},resolve(_,{id}){returnfetchDataFunction.es.get({// function does not exist on 'get' object but on 'es'dataSource: 'marketplace.storefronts',
id
}).then((response)=>{constdoc=response.hits[0];return_.storefronts.map(doc,true,true);}).catch((err)=>{thrownewError(Boom.wrap(err));})}}}});
Deliberate TypeError, statusCode of 500 is sent back to Client
server.register({register: graphqlHapi,options : {path : '/graphql',graphqlOptions: {schema : schema,graphiql : true,rootValue: server.methods,formatResponse: function(){},context: {name: 'Samuel Joli'}}}});constfetchDataFunction={}fetchDataFunction.get=function(){/* Fetch some data */}// Deliberate incorrect namespacingconstquery=newgraphql.GraphQLObjectType({name : 'Query',fields: {storefront: {type: Storefront,args: {id: {type: graphql.GraphQLString}},resolve(_,{id}){returnfetchDataFunction.es.get({// function does not exist on 'get' object but on 'es'dataSource: 'marketplace.storefronts',
id
}).then((response)=>{constdoc=response.hits[0];return_.storefronts.map(doc,true,true);}).catch((err)=>{thrownewError(Boom.wrap(err));})}}}});
The text was updated successfully, but these errors were encountered:
GraphQL servers don't typically return HTTP response codes in case of failure, they return the errors as errors field in the response. So not returning 500 is an expected behaviour.
However, there seems to be a bug in the lib that causes the server to crash when the formatResponse returns undefined, like in the second case here. I've added an issue for this #487.
@freiksenet Ahhh Yeah I've definitely read up some more on the technology that is graphql and it's definitely a shift in thinking when it comes to api development. I'll look into issue 487. Also do you guys/gals think it would be helpful if we introduced framework specific labels?
Versions
16.x.x
1.x.x
v6.5.0
Issue
Unless I add the config option of
formatResponse
if I encounter a typeError in my internal server logic I will get back a statusCode of200
. When I addformatResponse
a 500 will surface as expected.Reproduce Error
200
is sent back to Client500
is sent back to ClientThe text was updated successfully, but these errors were encountered: