Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
values.push(b.property(
'init',
b.literal(enumKey),
b.objectExpression([
b.property('init', b.identifier('value'), b.literal(enumValue.value)),
generateDescription(enumValue.description)
])
));
}
var typeDeclaration = b.objectExpression([
b.property('init', b.identifier('name'), b.literal(model.name + capitalize(field.name))),
generateDescription(field.description),
b.property('init', b.identifier('values'), b.objectExpression(values))
]);
return b.newExpression(
b.identifier('GraphQLEnumType'),
[typeDeclaration]
);
}
}
function buildObject(obj) {
var fields = [], key;
for (key in obj) {
fields.push(b.property('init', b.literal(key), castValue(obj[key])));
}
return b.objectExpression(fields);
}
function wrapExternalModule(modulePath: string, context: PaeckchenContext): Promise {
const external = context.config.externals[modulePath] === false
? b.objectExpression([])
: b.identifier(context.config.externals[modulePath] as string);
return Promise.resolve(b.program([
b.expressionStatement(
b.assignmentExpression(
'=',
b.memberExpression(
b.identifier('module'),
b.identifier('exports'),
false
),
external
)
)
]));
}
}
return buildVar('schema',
b.newExpression(
b.identifier('GraphQLSchema'),
[b.objectExpression([
b.property(
'init',
b.identifier('query'),
b.newExpression(
b.identifier('GraphQLObjectType'),
[b.objectExpression([
b.property('init', b.identifier('name'), b.literal('RootQueryType')),
b.property('init', b.identifier('fields'), buildFieldWrapperFunction(
'RootQuery',
b.objectExpression(queryFields),
opts
))
])]
)
)
])]
)
);
};
function buildConnectionsVar(opts) {
if (!opts.relay) {
return [];
}
return [buildVariable('connections', b.objectExpression([]), opts.es6)];
}
fields.push(generateListReferenceField(ref));
});
var interfaces = opts.relay && b.property(
'init',
b.identifier('interfaces'),
b.arrayExpression([b.identifier('nodeInterface')])
);
var typeDeclaration = b.objectExpression([
b.property('init', b.identifier('name'), b.literal(name)),
generateDescription(model.description),
b.property(
'init',
b.identifier('fields'),
buildFieldWrapperFunction(name, b.objectExpression(fields), opts)
)
].concat(interfaces || []));
return {
ast: buildVar(
name + 'Type',
b.newExpression(
b.identifier('GraphQLObjectType'),
[typeDeclaration]
),
opts.es6
)
};
}
_renderJsExports(classes) {
return escodegen.generate(b.assignmentExpression(
'=',
b.memberExpression(
b.identifier('module'),
b.identifier('exports')
),
b.objectExpression(
classes.map((object) => b.property(
'init',
b.identifier(this._getJsInterfaceName(object['$id'])),
b.identifier(this._getJsInterfaceName(object['$id']))
))
)
));
}
}
if (!enumKey.match(enumRegex)) {
enumKey = 'ENUM_' + enumKey;
}
values.push(b.property(
'init',
b.literal(enumKey),
b.objectExpression([
b.property('init', b.identifier('value'), b.literal(enumValue.value)),
generateDescription(enumValue.description)
])
));
}
var typeDeclaration = b.objectExpression([
b.property('init', b.identifier('name'), b.literal(model.name + capitalize(field.name))),
generateDescription(field.description),
b.property('init', b.identifier('values'), b.objectExpression(values))
]);
return b.newExpression(
b.identifier('GraphQLEnumType'),
[typeDeclaration]
);
}
}