I have postgraphile running on an express server (as a library)
export const postGraphileServer = () => {
return postgraphile(process.env.DB_DSN, 'public', options);
};
Express:
app.use(postGraphileServer());
Using the codegen introspection plugin I am generating a graphql.schema.json
and everything works correctly when GQL is accessed externally via an http link.
yml snippit:
packages/graphql/src/generated/graphql.schema.json:
plugins:
- 'introspection'
I have a use case for exposing a REST endpoint on the express server which would take a payload and create a row in Postgres. What I would like to do is access Postgraphile directly (without a network hop) to avoid auth - I believe using schema only
From what I have read the way to do this is via a SchemaLink
. I've tried something like:
const clientSchema = buildClientSchema(schema as unknown as IntrospectionQuery);
// Make executable schema from client schema
const executableSchema = makeExecutableSchema({
typeDefs: clientSchema,
});
return (this.#_apolloClient = new ApolloClient({
ssrMode: true,
link: new SchemaLink({ schema: executableSchema }),
cache: new InMemoryCache(),
}));
Where schema
is the codegen generated graphql.schema.json
file. I believe the issue I have is I also need to pass the resolvers to makeExecutableSchema
so that Postgraphile knows how to query / mutate - currently it silently fails but does nothing.
Am I on the correct path here and is there a way to access the generated resolvers from postgraphile (or do I need to manually create them for this specific use case?)