Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.join('\n')}`,
);
const { schema, errors } = composeAndValidate(serviceList);
if (errors && errors.length > 0) {
if (this.experimental_didFailComposition) {
this.experimental_didFailComposition({
errors,
serviceList,
...(this.compositionMetadata && {
compositionMetadata: this.compositionMetadata,
}),
});
}
throw new GraphQLSchemaValidationError(errors);
}
this.createServices(serviceList);
this.logger.debug('Schema loaded and ready for execution');
// this is a temporary workaround for GraphQLFieldExtensions automatic
// wrapping of all fields when using ApolloServer. Here we wrap all fields
// with support for resolving aliases as part of the root value which
// happens because alises are resolved by sub services and the shape
// of the rootvalue already contains the aliased fields as responseNames
return wrapSchemaWithAliasResolver(schema);
}
),
] as [string, LocalGraphQLDataSource];
}),
);
let errors: GraphQLError[];
({ schema, errors } = composeAndValidate(
Object.entries(serviceMap).map(([serviceName, service]) => ({
name: serviceName,
typeDefs: service.sdl(),
})),
));
if (errors && errors.length > 0) {
throw new GraphQLSchemaValidationError(errors);
}
const operationContext = buildOperationContext(schema, request.query);
const queryPlan = buildQueryPlan(operationContext);
const result = await executeQueryPlan(
queryPlan,
serviceMap,
{
cache: undefined as any,
context: {},
request,
},
operationContext,
);