File tree Expand file tree Collapse file tree
packages/apollo-language-server/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -272,10 +272,13 @@ export class ApolloEngineClient extends GraphQLDataSource {
272272 variables : {
273273 id : serviceID
274274 }
275- } ) ;
275+ } ) . catch ( e => e ) ;
276276
277277 if ( ! ( data && data . service ) ) {
278- throw new Error ( ) ;
278+ if ( errors ) {
279+ throw new Error ( errors . map ( error => error . message ) . join ( "\n" ) ) ;
280+ }
281+ throw new Error ( "No service found. Check your service name and API key" ) ;
279282 }
280283
281284 const schemaTags : string [ ] = data . service . schemaTags . map (
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import gql from "graphql-tag";
44import { GraphQLSchema , buildClientSchema } from "graphql" ;
55import { ApolloEngineClient , ClientIdentity } from "../../engine" ;
66import { ClientConfig , parseServiceSpecifier } from "../../config" ;
7+ import { getServiceFromKey } from "../../config/utils" ;
78import {
89 GraphQLSchemaProvider ,
910 SchemaChangeUnsubscribeHandler ,
@@ -44,6 +45,15 @@ export class EngineSchemaProvider implements GraphQLSchemaProvider {
4445 }
4546
4647 const [ id , tag = "current" ] = parseServiceSpecifier ( client . service ) ;
48+
49+ // make sure the API key is valid for the service we're requesting a schema of.
50+ const keyServiceName = getServiceFromKey ( engine . apiKey ) ;
51+ if ( id !== keyServiceName ) {
52+ throw new Error (
53+ `API key service name (${ keyServiceName } ) does not match the service name in your config (${ id } ). Try changing the service name in your config to ${ keyServiceName } or get a new key.`
54+ ) ;
55+ }
56+
4757 const { data, errors } = await this . client . execute < GetSchemaByTag > ( {
4858 query : SCHEMA_QUERY ,
4959 variables : {
You can’t perform that action at this time.
0 commit comments