Skip to content

Commit a4c2b50

Browse files
committed
wip
1 parent 211c09b commit a4c2b50

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

packages/apollo-language-server/src/engine/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff 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(

packages/apollo-language-server/src/providers/schema/engine.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import gql from "graphql-tag";
44
import { GraphQLSchema, buildClientSchema } from "graphql";
55
import { ApolloEngineClient, ClientIdentity } from "../../engine";
66
import { ClientConfig, parseServiceSpecifier } from "../../config";
7+
import { getServiceFromKey } from "../../config/utils";
78
import {
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: {

0 commit comments

Comments
 (0)