This commit is contained in:
101
node_modules/apollo-cache/lib/utils.js
generated
vendored
Normal file
101
node_modules/apollo-cache/lib/utils.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function queryFromPojo(obj) {
|
||||
var op = {
|
||||
kind: 'OperationDefinition',
|
||||
operation: 'query',
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: 'GeneratedClientQuery',
|
||||
},
|
||||
selectionSet: selectionSetFromObj(obj),
|
||||
};
|
||||
var out = {
|
||||
kind: 'Document',
|
||||
definitions: [op],
|
||||
};
|
||||
return out;
|
||||
}
|
||||
exports.queryFromPojo = queryFromPojo;
|
||||
function fragmentFromPojo(obj, typename) {
|
||||
var frag = {
|
||||
kind: 'FragmentDefinition',
|
||||
typeCondition: {
|
||||
kind: 'NamedType',
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: typename || '__FakeType',
|
||||
},
|
||||
},
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: 'GeneratedClientQuery',
|
||||
},
|
||||
selectionSet: selectionSetFromObj(obj),
|
||||
};
|
||||
var out = {
|
||||
kind: 'Document',
|
||||
definitions: [frag],
|
||||
};
|
||||
return out;
|
||||
}
|
||||
exports.fragmentFromPojo = fragmentFromPojo;
|
||||
function selectionSetFromObj(obj) {
|
||||
if (typeof obj === 'number' ||
|
||||
typeof obj === 'boolean' ||
|
||||
typeof obj === 'string' ||
|
||||
typeof obj === 'undefined' ||
|
||||
obj === null) {
|
||||
return null;
|
||||
}
|
||||
if (Array.isArray(obj)) {
|
||||
return selectionSetFromObj(obj[0]);
|
||||
}
|
||||
var selections = [];
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
var nestedSelSet = selectionSetFromObj(obj[key]);
|
||||
var field = {
|
||||
kind: 'Field',
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: key,
|
||||
},
|
||||
selectionSet: nestedSelSet || undefined,
|
||||
};
|
||||
selections.push(field);
|
||||
});
|
||||
var selectionSet = {
|
||||
kind: 'SelectionSet',
|
||||
selections: selections,
|
||||
};
|
||||
return selectionSet;
|
||||
}
|
||||
exports.justTypenameQuery = {
|
||||
kind: 'Document',
|
||||
definitions: [
|
||||
{
|
||||
kind: 'OperationDefinition',
|
||||
operation: 'query',
|
||||
name: null,
|
||||
variableDefinitions: null,
|
||||
directives: [],
|
||||
selectionSet: {
|
||||
kind: 'SelectionSet',
|
||||
selections: [
|
||||
{
|
||||
kind: 'Field',
|
||||
alias: null,
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: '__typename',
|
||||
},
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
//# sourceMappingURL=utils.js.map
|
||||
Reference in New Issue
Block a user