1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.schemaProviderFromConfig = void 0;
|
4 | const config_1 = require("../../config");
|
5 | const endpoint_1 = require("./endpoint");
|
6 | const engine_1 = require("./engine");
|
7 | const file_1 = require("./file");
|
8 | function schemaProviderFromConfig(config, clientIdentity) {
|
9 | if (config.service && config.service.localSchemaFile) {
|
10 | const isListOfSchemaFiles = Array.isArray(config.service.localSchemaFile);
|
11 | return new file_1.FileSchemaProvider(isListOfSchemaFiles
|
12 | ? { paths: config.service.localSchemaFile }
|
13 | : { path: config.service.localSchemaFile });
|
14 | }
|
15 | if (config.service && config.service.endpoint) {
|
16 | return new endpoint_1.EndpointSchemaProvider(config.service.endpoint);
|
17 | }
|
18 | if (config_1.isClientConfig(config)) {
|
19 | if (typeof config.client.service === "string") {
|
20 | return new engine_1.EngineSchemaProvider(config, clientIdentity);
|
21 | }
|
22 | if (config.client.service) {
|
23 | if (config_1.isLocalServiceConfig(config.client.service)) {
|
24 | const isListOfSchemaFiles = Array.isArray(config.client.service.localSchemaFile);
|
25 | return new file_1.FileSchemaProvider(isListOfSchemaFiles
|
26 | ? { paths: config.client.service.localSchemaFile }
|
27 | : {
|
28 | path: config.client.service.localSchemaFile
|
29 | });
|
30 | }
|
31 | return new endpoint_1.EndpointSchemaProvider(config.client.service);
|
32 | }
|
33 | }
|
34 | if (config.graph && config.engine) {
|
35 | return new engine_1.EngineSchemaProvider(config, clientIdentity);
|
36 | }
|
37 | throw new Error("No schema provider was created, because the project type was unable to be resolved from your config. Please add either a client or service config. For more information, please refer to https://go.apollo.dev/t/config");
|
38 | }
|
39 | exports.schemaProviderFromConfig = schemaProviderFromConfig;
|
40 |
|
\ | No newline at end of file |