I have CF with trigger type, it calls after Orders table mutated, currently I can get data from order table but also i need data from Managers table. How can I do it?
Hello Roman!
You can get required data with second argument passed to CF - ctx. It exposes ability to make graphql requests to your api. Here’s an example:
module.exports = async (event, ctx) => {
const response = await ctx.api.gqlRequest(YOUR_MANAGERS_LIST_QUERY);
};
Please let me know if this helps.
1 Like
When I import graphql-tag I get next error. Could you help me?
My code:
import { get } from "lodash";
import gql from "graphql-tag";
const MANAGERS_LIST_QUERY = gql`
query managersList($after: String) {
managersList(first: 8, after: $after) {
items {
id
telegramUsername
}
}
}
;
module.exports = async (event, ctx) => {
const data = get(event, "data");
const response = await ctx.api.gqlRequest(MANAGERS_LIST_QUERY);
return {
data
};
};
Roman, did you install graphql package? graphql-tag requires graphql as a peer dependency.
1 Like
Sorry, I forgot do it
1 Like