Skip to content

Instantly share code, notes, and snippets.

@akkonrad
Last active October 23, 2022 17:37
Show Gist options
  • Save akkonrad/b17e53ad0420efe1ddc5c29f244ee0af to your computer and use it in GitHub Desktop.
Save akkonrad/b17e53ad0420efe1ddc5c29f244ee0af to your computer and use it in GitHub Desktop.
app/gql/gql.module.ts
export const gqlProviderFactory = async () => {
const { NEO4J_URI, NEO4J_USERNAME, NEO4J_PASSWORD } = process.env;
const driver = neo4j.driver(
NEO4J_URI,
neo4j.auth.basic(NEO4J_USERNAME, NEO4J_PASSWORD)
);
const neoSchema = new Neo4jGraphQL({
typeDefs,
driver
});
const schema = await neoSchema.getSchema();
await neoSchema.assertIndexesAndConstraints({
options: { create: true }
});
return {
playground: true,
schema
};
};
@Module({
imports: [
GraphQLModule.forRootAsync<ApolloDriverConfig>({
driver: ApolloDriver,
useFactory: gqlProviderFactory
})
]
})
export class GqlModule {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment