mirror of
https://github.com/CamHenlin/MessagesForMacintosh.git
synced 2024-12-01 21:50:32 +00:00
101 lines
2.6 KiB
JavaScript
101 lines
2.6 KiB
JavaScript
"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
|