-
Notifications
You must be signed in to change notification settings - Fork 44
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
feat: Move relation field properties onto collection #2529
feat: Move relation field properties onto collection #2529
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2529 +/- ##
===========================================
- Coverage 75.81% 75.59% -0.22%
===========================================
Files 293 292 -1
Lines 27924 28180 +256
===========================================
+ Hits 21168 21301 +133
- Misses 5411 5510 +99
- Partials 1345 1369 +24
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 47 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
return NewLocalFieldDefinition( | ||
collectionField, | ||
), true | ||
} else if !existsOnCollection && existsOnSchema { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Can you explain how this will ever be the case? Even the embedded object doesn't seem to make sense to me here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have this at the moment, e.g. related objects within a view (declared with interface
instead of type
in an SDL).
Embedded objects do not have 'stuff' declared on a collection description, they are schema-only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(discussed in a call)
todo: The documentation for local-only vs local-global vs global-only fields is insufficient and dispersed. I will add more public documentation to the relevant client
types/props.
- Expand docs
6610a0a
to
297faeb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any blocking issues. Looks great considering the impact of the changes.
validateSingleSidePrimary, | ||
} | ||
|
||
func (db *db) validateNewCollection( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: this is a nice pattern
thought: may be worth moving to db_validators.go
at some point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:) Cheers
thought: may be worth moving to db_validators.go at some point
I want to move them somewhere, and there are other improvements that can be made too, but I started doing it in here before pausing and deciding that it would require too much thought for an already fiddly PR (noted in the description, I'll be creating a ticket once people are happy with this PR being merged).
request/graphql/schema/relations.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: nice to not need this anymore
297faeb
to
e26ee8b
Compare
We'll need to call this somewhere else soon too.
Is really not worth having two slightly different messages for the same thing
Soon, secondary fields will not exist on the schema
Old name was incorrect, as it gets the field ID (hosted on collection) from the collection definition, not the schema. Should have been changed a while ago
Not from relation name, which is no longer required for relations
From schema.
Broken out of 'Move relation field properties onto collection' as to not clutter the diff for reviewers.
Secondary fields do not exist in the schema, and thus schema.fields is incorrect here.
a759a7c
to
9c4fe72
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Right now I'm a little worried that we have made our Schema and Collection system more complex than it needs to be. Hopefully the future will put those worry to rest :)
request/graphql/schema/collection.go
Outdated
// An _id field is added for every 1-1 or 1-N relationship from this object if the relation | ||
// does not point to an embedded object. | ||
// | ||
// It is inserted immediately after the object field for make things nicer for the user. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: field to make
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😁 will fix
- Fix typo
I understand that, but I'm not really sure there is much we can do to simplify it without breaking the local/global boundary, or by falling back into the pointer-based problems we used to have. I am a bit concerned at the increased prominence of |
Relevant issue(s)
Resolves #2451 #1911 #2408
Description
Moves relation field properties onto collection description from schema description.
This allows for one-sided relations to be defined via
PatchSchema
. There is no way atm to create them using an SDL, but we could add a directive or something at somepoint if we want.As the adding of fields via
PatchCollection
has not yet been enabled, this does prevent users from adding secondary relation fields to an existing schema. I'll create a ticket before merging this to allow this, it is my strong preference to not do that in this already large and fiddly PR though.As the internal codebase relies on the setting of secondary fields via
client.Document
,client.Document
now requires a collection, not just the schema, when being constructed. We will likely want to find a way to avoid that in the future.This PR also moves some validation from the graphql package into
db
, not all of it has been moved, but that is a long term wish of mine. Thedb
package validation can/should be improved further making rule reuse acrossPatchCollection
,PatchSchema
andCreateCollection
(SDL), however I would rather not spend too much effort on that in this PR. This includes moving it out of thecollection.go
file.It might resolve #2380 but I'd rather not bring that into scope. If I'm waiting around for reviews I might verify that here though.
This should conclude the transfer of local properties off of the schema object :)
Commits should be clean, however the vast majority of the work was done in
Move relation field properties onto collection from schema
.Todos (now)
Todos (post review)
PatchCollection
db
schema/col validation