Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
compile(model, store, options) {
options = options || {};
let operationType = options['operationType']; // TODO: Must be query or mutation
let operationName = options['operationName'];
let operation = new Operation(operationType, operationName);
let rootFieldQuery = options['rootFieldQuery'] || {};
let rootFieldName = options['rootFieldName'] || model.modelName;
let rootFieldAlias = options['rootFieldAlias'];
let rootField = new Field(rootFieldName, rootFieldAlias, ArgumentSet.fromQuery(rootFieldQuery));
Parser.parse(model, store, operation, rootField, options);
return Generator.generate(operation);
}
};
generateArgument({name, value}) {
if (typeOf(value) === 'string') {
value = this.wrapInStringTokens(value);
} else if (typeOf(value) === 'array') {
value = this.argumentArrayOpeningToken + this.wrapArrayInStringTokens(value) + this.argumentArrayClosingToken;
} else if (value instanceof SelectionSet || value instanceof ArgumentSet) {
value = this.argumentObjectOpeningToken + this.generateArgumentSet(value) + this.argumentObjectClosingToken;
} else if (typeOf(value) === 'object') {
value = ArgumentSet.fromQuery(value);
value = this.argumentObjectOpeningToken + this.generateArgumentSet(value) + this.argumentObjectClosingToken;
}
return name + this.argumentKeyValueSeparateToken + value;
},