-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Poor performance when using GraphQL Library and OGM, due to slow schema generation happening twice #243
Comments
Thanks for opening this issue @aspectgfg! Can I ask you, how large is the typedefs in:
How long does the booting take for you? This is something that hasn't come up before. I see some complexity with sharing a schema in that the GraphQL library and the OGM interprets the typedefs differently ( |
Over 55k lines in GraphQL syntax
That's a little odd. I'd expect if the directive has different behavior in each lib, they should be different directives. |
@aspectgfg Thanks for the info!
The OGM ignores the |
@aspectgfg, whilst we could generate some super large type definitions to benchmark against ourselves, it would be much easier and much more realistic to use some real type definitions. If there's any way at all that you could give us your type definitions, then we could set up some benchmarking tests to help us improve performance and ensure that performance does not drop in the future. Fully understand if they are private for whatever reason! |
@darrellwarde yeah here's our GQL Schema for the FHIR data model This is FHIR: |
@darrellwarde being able to precompile the graphql schema would be phenomenal, we hit 95000 types on the FHIR schema. it's pretty insane. |
@aspectgfg @darrellwarde Precompiling the graphql schema could be a big improvement for serverless use. As this would greatly reduce cold start times. |
Hey @aspectgfg and @mathix420, thanks for the feedback, I understand your pain on the performance impacts of generating the schema on every server startup. Out of interest, what would you imagine schema pre-compilation would look like, especially in the context of resolvers? I imagine you would not expect a Interested to hear your ideas! |
Hi @darrellwarde, nice to see your interest on this! I was thinking basically the same as you. To summarise a little, a CLI or a plugin for babel, rollup, or webpack which is capable of converting the neo4j graphql schema into AST. Even better if it can then allow to get OGM models typings in typescript projects (like mongoose typings). |
Have there been any more thoughts on this? I'm seeing 6 second cold starts on AWS lambda now that I use the OGM in resolvers, about double the delay with just the autogenerated ones. |
Same here, 6 second cold start that prevents auto-scaling (new instance spawning introducing 6s latency on the loading request). |
Neo4j is a powerful tool, but this problem and the fact that it can take 500ms to a few seconds to establish a connection to neo4j means that we wiull likely move away from Neo4j. |
This issue could also be addressed by fixing this one ardatan/graphql-tools#4270 Executing |
Bun's Macros could be the easiest solution to this problem, but unfortunately right now Bun do not support compiling circular structures (oven-sh/bun#5271). Once this feature implemented the only thing we would need to do is import our function that generate the schema and ogm with the macro syntax. neo4j.ts import { Neo4jGraphQLConstructor } from "@neo4j/graphql";
import { OGM } from "@neo4j/graphql-ogm";
const neoSchema: Neo4jGraphQLConstructor = {
resolvers: {
...resolvers,
...scalars,
},
typeDefs: typeDefs,
driver,
};
const ogm = new OGM(neoSchema);
export async function getSchemaOgm(): Promise<[GraphQLSchema, void]> {
return Promise.all([neoSchema.getSchema(), ogm.init()]);
} index.ts import { getSchemaOgm } from "./neo4j" with { type: 'macro' }; Then run |
On our server where we're using both OGM and Neo4JSchema. Our GQL schema is extremely large and Neo4jSchema/OGM are impacting boot times on our server. If we could have a single neo4jschema, our boot times would be reduced drastically. Please allow OGM constructor to accept Neo4JSchema
Our init:
The text was updated successfully, but these errors were encountered: