Last active
October 23, 2022 17:37
-
-
Save akkonrad/b17e53ad0420efe1ddc5c29f244ee0af to your computer and use it in GitHub Desktop.
app/gql/gql.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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