Skip to content
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

Asynchronous schema generation and OGM initialization #896

Merged
merged 40 commits into from
Feb 11, 2022

Conversation

darrellwarde
Copy link
Contributor

Description

This PR moves the heavy lifting of the Neo4jGraphQL and OGM constructors into asynchronous functions, getSchema() and init(), respectively.

This means that construction will be quick and these functions will have to be awaited following construction. Whilst this may seem like a nuisance right now, in the future this will open doors to more performant schema generation through asynchronous processing.

Checklist

The following requirements should have been met (depending on the changes in the branch):

  • Documentation has been updated
  • TCK tests have been updated
  • Integration tests have been updated
  • Example applications have been updated
  • New files have copyright header
  • CLA (https://neo4j.com/developer/cla/) has been signed

@github-actions github-actions bot added documentation Improvements or additions to documentation ogm labels Feb 4, 2022
@neo4j-team-graphql
Copy link
Collaborator

neo4j-team-graphql commented Feb 4, 2022

Thanks for the documentation updates.

The preview documentation has now been torn down - reopening this PR will republish it.

@github-actions github-actions bot removed the feature label Feb 10, 2022
@wheresrhys
Copy link

Great that this is happening. I guess this means you'll be going for a new major release reasonably soon. Any idea of roughly when the release is scheduled?

@darrellwarde
Copy link
Contributor Author

darrellwarde commented Feb 10, 2022

Great that this is happening. I guess this means you'll be going for a new major release reasonably soon. Any idea of roughly when the release is scheduled?

Hey @wheresrhys! We wouldn't normally give timelines, but this release has a fairly strict schedule, so you can expect this next week! 🙂 It won't be as much of a jarring release as 2.0.0, but certainly some nice changes to come.

Copy link
Member

@angrykoala angrykoala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, the solution looks solid, I just commented on a few style/legibility suggestions and improvements

docs/modules/ROOT/pages/api-reference/neo4jgraphql.adoc Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/ogm/api-reference/ogm.adoc Outdated Show resolved Hide resolved
packages/graphql/src/classes/Neo4jGraphQL.ts Outdated Show resolved Hide resolved
packages/graphql/src/classes/Neo4jGraphQL.ts Outdated Show resolved Hide resolved
packages/graphql/src/classes/Neo4jGraphQL.ts Outdated Show resolved Hide resolved
packages/graphql/src/utils/execute.test.ts Show resolved Hide resolved
packages/ogm/src/classes/OGM.ts Show resolved Hide resolved
packages/ogm/src/classes/OGM.ts Outdated Show resolved Hide resolved
packages/ogm/src/classes/OGM.ts Outdated Show resolved Hide resolved
angrykoala
angrykoala previously approved these changes Feb 11, 2022
angrykoala
angrykoala previously approved these changes Feb 11, 2022
@@ -128,6 +128,50 @@ class Neo4jGraphQL {
await assertIndexesAndConstraints({ driver, driverConfig, nodes: this.nodes, options: input.options });
}

private wrapResolvers(resolvers: IResolvers, { schema }: { schema: GraphQLSchema }) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (non-blocking): Maybe we could move these functions to the bottom?
Usually, it is slightly easier to read functions in a class from more abstract to less abstract (kind of like articles are composed). So, first, we read generateSchema at the top, and then, if we need to, we keep going to the functions that are used by that one

packages/graphql/src/classes/Neo4jGraphQL.ts Outdated Show resolved Hide resolved
packages/graphql/src/classes/Neo4jGraphQL.ts Outdated Show resolved Hide resolved
packages/graphql/src/classes/Neo4jGraphQL.ts Outdated Show resolved Hide resolved
@darrellwarde darrellwarde changed the title Async schema generation Asynchronous schema generation and OGM initialization Feb 11, 2022
@darrellwarde darrellwarde merged commit c4c8ed1 into neo4j:dev Feb 11, 2022
@darrellwarde darrellwarde deleted the async-schema branch May 9, 2022 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation feature ogm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants