parseLiteral(ast) { if (ast.kind === _graphql.Kind.STRING) { return parseFileValue(ast.value); } else if (ast.kind === _graphql.Kind.OBJECT) { const __type = ast.fields.find(field => field.name.value === '__type'); const name = ast.fields.find(field => field.name.value === 'name'); const url = ast.fields.find(field => field.name.value === 'url'); if (__type && __type.value && name && name.value) { return parseFileValue({ __type: __type.value.value, name: name.value.value, url: url && url.value ? url.value.value : undefined }); } } throw new TypeValidationError(ast.kind, 'File'); }
parseLiteral(ast) { if (ast.kind === _graphql.Kind.STRING) { return { __type: 'Date', iso: parseDateIsoLiteral(ast) }; } else if (ast.kind === _graphql.Kind.OBJECT) { const __type = ast.fields.find(field => field.name.value === '__type'); const iso = ast.fields.find(field => field.name.value === 'iso'); if (__type && __type.value && __type.value.value === 'Date' && iso) { return { __type: __type.value.value, iso: parseDateIsoLiteral(iso.value) }; } } throw new TypeValidationError(ast.kind, 'Date'); }
'Multiple operations present in GraphQL query, you must specify an `operationName` so we know which one to execute.', ); } else if (!operationName || (definition.name && definition.name.value === operationName)) { operation = definition; sqlSettings.unshift(sql.fragment`set_config(${sql.value(key)}, ${sql.value(value)}, true)`);
parseLiteral(ast) { if (ast.kind === _graphql.Kind.STRING) { return { __type: 'Bytes', base64: ast.value }; } else if (ast.kind === _graphql.Kind.OBJECT) { const __type = ast.fields.find(field => field.name.value === '__type'); const base64 = ast.fields.find(field => field.name.value === 'base64'); if (__type && __type.value && __type.value.value === 'Bytes' && base64 && base64.value && typeof base64.value.value === 'string') { return { __type: __type.value.value, base64: base64.value.value }; } } throw new TypeValidationError(ast.kind, 'Bytes'); }
const _mergeSchema = (module1, module2) => { const parsedModule1Schema = parse(new Source(module1.schema.join('\n'))) const parsedModule2Schema = parse(new Source(module2.schema.join('\n'))) const mergedSchema = { kind: 'Document', definitions: [ ...parsedModule1Schema.definitions.filter(def => def.kind === 'SchemaDefinition'), ...parsedModule1Schema.definitions .filter(def => def.kind === 'ObjectTypeDefinition') .map(def => { const objectTypeDefsModule2 = parsedModule2Schema.definitions .find(def2 => def2.kind === 'ObjectTypeDefinition' && def2.name.value === def.name.value ) return { ...def, fields: [ ...def.fields, ...objectTypeDefsModule2 ? objectTypeDefsModule2.fields : [] ] } }) ] } return print(mergedSchema) }