I have an ApolloServer running locally and on Firebase cloud functions.
I want to send a Stripe API webhook to it.
I tried to see if I can find documentation on how to call the server directly, but all I can find are documentations on using the playground to run queries.
Suppose this is my ApolloServer:
new ApolloClient({
uri: `localhost:4000/graphql`,
cache: new InMemoryCache(),
});
And this is my server:
import { ApolloServer } from "apollo-server-express";
import express from "express";
import schema from "./schema";
import resolvers from "./resolvers";
import PaymentsAPI from "./datasources/payments";
const initServer = () => {
const app = express();
const server = new ApolloServer({
typeDefs: schema,
resolvers,
dataSources: () => {
return {
paymentsAPI: new PaymentsAPI(),
};
},
uploads: false,
introspection: true,
playground: true,
context: async ({ req }) => {
return {
request: req,
};
},
});
server.applyMiddleware({ app, path: "/", cors: true });
return app;
};
export default initServer;
How do I send a post request to it without using the playground... for example, using Postman.
And my second question - I believe that the webhook will be another function in my PaymentsAPI datasource / resolver / schema. Am I right? Is it a Mutation? a Query? I am assuming Mutation as I will be saving some data to the db?