Tags: brigade/apollo-server
Tags
Avoid `TypeError` when querystring is present, but `query` missing The express-graphql reference implementation [provides a check] (https://github.com/graphql/express-graphql/blob/2e27a7335875f23ae5cccc97a9d6926970fb08c3/src/index.js#L201-L208) to protect against cases where a GET request is made that does not have a `query` parameter where the GraphQL query would be present. Without this guard, graphql-js's `parse` will return `undefined` for the `DocumentNode` since it has no document to read. Subsequently passing this to `isQueryOperation` results in a `TypeError`, because we are providing `undefined` where `getOperationAst` [expects to get a DocumentNode](https://github.com/graphql/graphql-js/blob/5fe39262a308df944a87cc85b225228e7556aaa4/src/utilities/getOperationAST.js#L19). A new test file is added for `runHttpQuery`, as one previously did not seem to exist.
PreviousNext