-
Notifications
You must be signed in to change notification settings - Fork 3
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
Rework for compatibility with TypeORM v0.3.x #538
Merged
Merged
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TypeORM v0.3.0 changed the way relations and data sources work. The
relations
option tofindX()
methods now expects an object instead of an array of strings (the array format is deprecated and will be removed in v0.4.0).This has necessitated significant changes to
typeorm-graphql-joiner
to use the new object format. A relations object now looks like:The library has been reworked to produce that kind of object, and to work with a TypeORM
DataSource
rather than a legacy TypeORMConnection
. 🔌A number of other changes and improvements have also been made:
GraphQLResolveInfo
into a separate package, 📦 graphql-info-inspectorrelations
objectto 📦 typeorm-relations-graphqltypeorm-graphql-joiner
RelationMapper
class toGraphRelationBuilder
buildRelationListForQuery
tobuildForQuery
buildRelationList
tobuild
Migration Guide
If you were using
typeorm-graphql-joiner
with TypeORM v0.2.x before, and you're upgrading to TypeORM v0.3.x, you'll need to do the following:Remove dependency
typeorm-graphql-joiner
in your package.jsonAdd dependency
typeorm-relations-graphql
in your package.jsonReplace code like:
with:
Replace code like:
with:
If you were using
relationMapper.isFieldSelected()
before, addgraphql-info-inspector
to your dependencies and use it like this:If you need to manipulate the relations after mapping what's selected by the GraphQL query (for example, when there are relations that you always want to fetch for other reasons), previously you could just modify the resulting
Set
orArray
of strings but now things are a little more complicated. HoweverGraphRelationBuilder
returns aRelationMap
instance which makes this easy: 🔥RelationMap
is provided by 📦 typeorm-relations, read its docs to see what else you can do with it.Additionally, make sure you're aware of TypeORM's own breaking changes when upgrading from v0.2.x to v0.3.0.