Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const internalGraphql = async restart => {
const app = express();
const contentTypeFieldType = new GraphQLObjectType({
name: 'ContentTypeField',
fields: omit(attributeFields(ContentTypeField), ['contentTypeId']),
});
const userType = new GraphQLObjectType({
name: 'User',
fields: {
...omit(attributeFields(User), ['password']),
roles: { type: new GraphQLList(GraphQLString) },
},
});
const contentTypeType = new GraphQLObjectType({
name: 'ContentType',
fields: () => ({
...attributeFields(ContentType),
schema: {
type: new GraphQLList(ContentTypeFieldGroup),
entriesCount: { type: GraphQLInt },
}),
});
const contentReleaseType = new GraphQLObjectType({
name: 'ContentRelease',
fields: () => ({
...attributeFields(ContentRelease),
documents: { type: GraphQLInt },
}),
});
const contentEntryType = new GraphQLObjectType({
name: 'ContentEntry',
fields: omit({
...attributeFields(ContentEntry),
contentType: {
type: contentTypeType,
resolve: resolver(ContentType, {
before(opts, args, context, info) {
opts.where = {
id: info.source.contentTypeId,
};
return opts;
},
}),
},
user: {
type: userType,
resolve: resolver(User, {
before(opts, args, context, info) {
fields: () =>
_.assign(
attributeFields(model),
generateReferences(references),
extraFields,
),
});
fields: () => _.assign(attributeFields(model), generateReferences(model, references), extraFields)
})
},
);
const pointerType = makeObjectType(Pointer, [
["pointerImport", () => pointerImportType],
["sourceBlock", () => blockType],
]);
const pointerImportType = makeObjectType(PointerImport, [
["workspace", () => blockType],
["pointer", () => pointerType],
]);
const BlockInput = new GraphQLInputObjectType({
name: "blockInput",
fields: _.pick(attributeFields(Block), "value", "id"),
});
const TreeInputForAPI = new GraphQLInputObjectType({
name: "treeInputForAPI",
fields: {
rootLevelQuestion: { type: GraphQLString },
rootLevelScratchpad: { type: GraphQLString },
honestAnswer: { type: GraphQLString },
maliciousAnswer: { type: GraphQLString },
emailsOfHonestOracles: { type: new GraphQLList(GraphQLString) },
emailsOfMaliciousOracles: { type: new GraphQLList(GraphQLString) },
doesAllowJudgeToJudge: { type: GraphQLBoolean },
isMIBWithoutRestarts: { type: GraphQLBoolean },
schedulingPriority: { type: GraphQLInt },
depthLimit: { type: GraphQLInt },
},
fields: () => ({
...attributeFields(WebhookModel),
success: { type: GraphQLInt },
count: { type: GraphQLInt },
}),
});
fields() {
const fields = attributeFields(model);
fieldAssociations.hasMany.forEach(associatedModel => {
fields[formatFieldName(associatedModel.name)] = {
type: new GraphQLList(types[associatedModel.name]),
args: defaultListArgs(model[associatedModel.name]),
resolve: resolver(model[associatedModel.name]),
};
});
fieldAssociations.belongsTo.forEach(associatedModel => {
const fieldName = singular(associatedModel.name);
fields[formatFieldName(fieldName)] = {
type: types[associatedModel.name],
resolve: resolver(model[fieldName]),
};
});
export const makeUpdateArgs = model => {
const fields = attributeFields(model);
return Object.keys(fields).reduce((acc, key) => {
const field = fields[key];
if (field.type instanceof GraphQLNonNull) {
field.type = field.type.ofType;
}
acc[key] = field;
return acc;
}, fields);
};
export const makePolyArgs = (model, otherModel) => {
const [key, otherKey, otherKeyFormatted] = getPolyKeys(model, otherModel);
const fields = attributeFields(model);
const otherFields = attributeFields(otherModel);
return {
[key]: fields[key],
[otherKeyFormatted]: otherFields[otherKey],
};
};