Hello,
I want to execute a graphql query from within a endpoint, but can't make it work.
What I want to do:
module.exports = function registerEndpoint(
router: Router,
{ services, env, exceptions },
) {
const { ServiceUnavailableException } = exceptions;
router.get("/test", async (req, res, next) => {
const { ItemsService, GraphQLService } = services;
const { schema, accountability } = req as Request & {
schema: any;
accountability: any;
};
const graphqlService: GraphQLService = new GraphQLService({
schema: schema,
accountability: accountability,
scope: "items",
});
//@ts-ignore
const data = await graphqlService.execute({
query: `query blabla`,
variables: { id: "bla"},
});
});
};
Does anyone have an idea on how to make this work?