Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Object.values(serviceMap).forEach(service => {
let resolvers = {};
if (service.__addMocks__) {
Object.entries(mocks).forEach(([type, value]) => {
resolvers[type] = {
__resolveReference() {
return value();
}
};
});
addResolversToSchema(service.schema, resolvers);
addMockFunctionsToSchema({
schema: service.schema,
preserveResolvers: true,
mocks
});
}
});
}
return undefined;
});
schema = transformSchema(schema, type => {
if (hasEntities && isUnionType(type) && type.name === EntityType.name) {
return new GraphQLUnionType({
...EntityType.toConfig(),
types: entityTypes.filter(isObjectType),
});
}
return undefined;
});
for (const module of modules) {
if (!module.resolvers) continue;
addResolversToSchema(schema, module.resolvers);
}
return schema;
}