UNPKG

675 BJavaScriptView Raw
1/**
2 * @internal
3 */
4export function pick(obj, keys) {
5 for (const key of keys) {
6 if (obj[key]) {
7 return obj[key];
8 }
9 }
10 return obj;
11}
12// checkers
13/**
14 * @internal
15 */
16export function isSchemaText(obj) {
17 return typeof obj === 'string';
18}
19/**
20 * @internal
21 */
22export function isWrappedSchemaJson(obj) {
23 const json = obj;
24 return json.data !== undefined && json.data.__schema !== undefined;
25}
26/**
27 * @internal
28 */
29export function isSchemaJson(obj) {
30 const json = obj;
31 return json !== undefined && json.__schema !== undefined;
32}
33/**
34 * @internal
35 */
36export function isSchemaAst(obj) {
37 return obj.kind !== undefined;
38}