Skip to content
  • Dmitri Shuralyov's avatar
    Unmarshal data field only if present. (#23) · 62c9ce09
    Dmitri Shuralyov authored
    The data field may not be present in the response from GraphQL server.
    This is valid according to GraphQL specification, section 7.2.1
    (https://facebook.github.io/graphql/October2016/#sec-Data):
    
    	If an error was encountered before execution begins, the data entry
    	should not be present in the result.
    
    If it's not present, it won't have a valid JSON value. As a result,
    jsonutil.UnmarshalGraphQL will return an "unexpected end of JSON input"
    error, and prevent errors from the GraphQL response from being returned.
    We don't want that, so only try to Unmarshal the data value if it's
    present in the response.
    
    Fixes #22.
    62c9ce09