apollographql / apollographql/federation

Masked error messages from RemoteGraphQLDataSource's willSendRequest

Open
#409 0 comments 0 reactions 1 assignee Claimed by @abernix View on GitHub
Dominant language
TypeScript
Stars
725
Forks
276
Avg merge
1h 47m
Merged PRs (30d)
1

Description

When using `ApolloGateway` with a `RemoteGraphQLDataSource` like this:

```js
const { ApolloServer } = require('apollo-server')
const { ApolloGateway, RemoteGraphQLDataSource } = require('@apollo/gateway')

class AuthenticatedDataSource extends RemoteGraphQLDataSource {
willSendRequest({ request, context }) {
foo
}
}

const gateway = new ApolloGateway({
serviceList: [
{ name: 'accounts', url: 'http://localhost:4001/graphql' }
],
buildService({ url }) {
return new AuthenticatedDataSource({ url })
}
})

const server = new ApolloServer({
gateway,
subscriptions: false,
engine: false
})

server.listen().then(({ url }) => {
console.log(`🚀 Gateway ready at ${url}`)
})
```

Anything wrong that happens inside `willSendRequest()` results in this error being logged every second (probably because I had Playground open, polling introspection):

```
(node:83623) UnhandledPromiseRejectionWarning: Error: Expected undefined to be a GraphQL schema.
at assertSchema (/Users/me/gh/guide-api/node_modules/graphql/type/schema.js:41:11)
at validateSchema (/Users/me/gh/guide-api/node_modules/graphql/type/validate.js:44:28)
at assertValidSchema (/Users/me/gh/guide-api/node_modules/graphql/type/validate.js:68:16)
at assertValidExecutionArguments (/Users/me/gh/guide-api/node_modules/graphql/execution/execute.js:136:35)
at executeImpl (/Users/me/gh/guide-api/node_modules/graphql/execution/execute.js:86:3)
at Object.execute (/Users/me/gh/guide-api/node_modules/graphql/execution/execute.js:64:63)
at Object.generateSchemaHash (/Users/me/gh/guide-api/node_modules/apollo-server-core/dist/utils/schemaHash.js:14:32)
at ApolloServer.generateSchemaDerivedData (/Users/me/gh/guide-api/node_modules/apollo-server-core/dist/ApolloServer.js:282:41)
at ApolloServerBase.schemaDerivedData._schema.then.schema (/Users/me/gh/guide-api/node_modules/apollo-server-core/dist/ApolloServer.js:206:66)
at
at process._tickCallback (internal/process/next_tick.js:188:7)(node:83623) UnhandledPromiseRejectionWarning: Error: Expected undefined to be a GraphQL schema.
at assertSchema (/Users/me/gh/guide-api/node_modules/graphql/type/schema.js:41:11)
at validateSchema (/Users/me/gh/guide-api/node_modules/graphql/type/validate.js:44:28)
at assertValidSchema (/Users/me/gh/guide-api/node_modules/graphql/type/validate.js:68:16)
at assertValidExecutionArguments (/Users/me/gh/guide-api/node_modules/graphql/execution/execute.js:136:35)
at executeImpl (/Users/me/gh/guide-api/node_modules/graphql/execution/execute.js:86:3)
at Object.execute (/Users/me/gh/guide-api/node_modules/graphql/execution/execute.js:64:63)
at Object.generateSchemaHash (/Users/me/gh/guide-api/node_modules/apollo-server-core/dist/utils/schemaHash.js:14:32)
at ApolloServer.generateSchemaDerivedData (/Users/me/gh/guide-api/node_modules/apollo-server-core/dist/ApolloServer.js:282:41)
at ApolloServerBase.schemaDerivedData._schema.then.schema (/Users/me/gh/guide-api/node_modules/apollo-server-core/dist/ApolloServer.js:206:66)
at
at process._tickCallback (internal/process/next_tick.js:188:7)(node:83623) UnhandledPromiseRejectionWarning: Error: Expected undefined to be a GraphQL schema.
at assertSchema (/Users/me/gh/guide-api/node_modules/graphql/type/schema.js:41:11)
at validateSchema (/Users/me/gh/guide-api/node_modules/graphql/type/validate.js:44:28)
at assertValidSchema (/Users/me/gh/guide-api/node_modules/graphql/type/validate.js:68:16)
at assertValidExecutionArguments (/Users/me/gh/guide-api/node_modules/graphql/execution/execute.js:136:35)
at executeImpl (/Users/me/gh/guide-api/node_modules/graphql/execution/execute.js:86:3)
at Object.execute (/Users/me/gh/guide-api/node_modules/graphql/execution/execute.js:64:63)
at Object.generateSchemaHash (/Users/me/gh/guide-api/node_modules/apollo-server-core/dist/utils/schemaHash.js:14:32)
at ApolloServer.generateSchemaDerivedData (/Users/me/gh/guide-api/node_modules/apollo-server-core/dist/ApolloServer.js:282:41)
at ApolloServerBase.schemaDerivedData._schema.then.schema (/Users/me/gh/guide-api/node_modules/apollo-server-core/dist/ApolloServer.js:206:66)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
```

Whereas the desired behavior is seeing an error message relevant to the error. In this example, I'd like to see `ReferenceError: foo is not defined`.

Related: the same error occurs when there aren't services running apollographql/apollo-server#3480

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.