UNPKG

1.02 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.isSchemaAst = exports.isSchemaJson = exports.isWrappedSchemaJson = exports.isSchemaText = exports.pick = void 0;
4/**
5 * @internal
6 */
7function pick(obj, keys) {
8 for (const key of keys) {
9 if (obj[key]) {
10 return obj[key];
11 }
12 }
13 return obj;
14}
15exports.pick = pick;
16// checkers
17/**
18 * @internal
19 */
20function isSchemaText(obj) {
21 return typeof obj === 'string';
22}
23exports.isSchemaText = isSchemaText;
24/**
25 * @internal
26 */
27function isWrappedSchemaJson(obj) {
28 const json = obj;
29 return json.data !== undefined && json.data.__schema !== undefined;
30}
31exports.isWrappedSchemaJson = isWrappedSchemaJson;
32/**
33 * @internal
34 */
35function isSchemaJson(obj) {
36 const json = obj;
37 return json !== undefined && json.__schema !== undefined;
38}
39exports.isSchemaJson = isSchemaJson;
40/**
41 * @internal
42 */
43function isSchemaAst(obj) {
44 return obj.kind !== undefined;
45}
46exports.isSchemaAst = isSchemaAst;