Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
error(messages.IS_MORE_THAN_MAXIMUM);
validate('}');
}
if (properties) {
Object.keys(properties).forEach(function(p) {
visit(genobj(name, p), genobj(dataSym, p), properties[p], reporter, filter);
});
}
while (indent--) {
validate('}');
}
}
let validate = genfun('function validate(data) {')('validate.errors = null')('var errors = 0');
visit('data', 'data', schema, reporter, opts && opts.filter);
validate('return errors === 0')('}');
validate = validate.toFunction(scope);
validate.errors = null;
validate.__defineGetter__('error', function() {
if (!validate.errors) {
return '';
} else {
return validate.errors
.map(err => err.field + ' ' + err.message)
.join('\n');
}
function generateInput(
context: CompilationContext,
varType: GraphQLInputType,
varName: string,
hasValueName: string,
wrapInList: boolean
) {
const currentOutput = getObjectPath(context.responsePath);
const currentInput = getObjectPath(context.inputPath);
const errorLocation = printErrorLocation(
computeLocations([context.varDefNode])
);
const gen = genFn();
gen(`if (${currentInput} == null) {`);
if (isNonNullType(varType)) {
let nonNullMessage;
let omittedMessage;
if (context.errorMessage) {
const objectPath = printObjectPath(context.responsePath);
nonNullMessage = `${
context.errorMessage
} + \`Expected non-nullable type ${varType} not to be null at ${objectPath}.\``;
omittedMessage = `${
context.errorMessage
} + \`Field ${objectPath} of required type ${varType} was not provided.\``;
} else {
nonNullMessage = `'Variable "$${varName}" of non-null type "${varType}" must not be null.'`;
omittedMessage = `'Variable "$${varName}" of required type "${varType}" was not provided.'`;
const createSameTypeTextNodes = textFormattings => {
let fn = generateFunction();
fn = fn('function (nodeA, nodeB) {');
fn = fn('return ' + textFormattings
.map(row => {
return row.property;
})
.filter(property => {
return property !== 'content';
})
.map(property => {
return 'nodeA[\'' + property + '\'] === nodeB[\'' + property + '\']';
})
.join('&&'));
fn = fn('}');
return fn.toFunction();
export default opts => {
const textFormattings = getTextFormattings(opts);
let fn = generateFunction();
const renderTextOpts = textFormattings.reduce((opts, row) => {
opts[row.property] = row.get;
if (row.classProperty) {
opts[row.classProperty] = row.getClass;
}
return opts;
}, {});
fn = fn('function text (opts, elm) {')('return {');
fn = fn(' type: \'text\',');
Object.keys(renderTextOpts).forEach(key => {
fn = fn(
' %s: opts[\'%s\'] || renderTextOpts[\'%s\'](elm),',
key, key, key);
if (typeof enricher === "function") {
enrichedInfo =
enricher({
fieldName,
fieldNodes,
returnType: fieldType,
parentType,
schema,
fragments,
operation
}) || {};
if (typeof enrichedInfo !== "object" || Array.isArray(enrichedInfo)) {
enrichedInfo = {};
}
}
const gen = genFn();
gen(`return function getGraphQLResolveInfo(rootValue, variableValues, path) {
return {
fieldName,
fieldNodes,
returnType: fieldType,
parentType,
path,
schema,
fragments,
rootValue,
operation,
variableValues,`);
Object.keys(enrichedInfo).forEach(key => {
gen(`${key}: enrichedInfo["${key}"],\n`);
});
gen(`};};`);