-
Notifications
You must be signed in to change notification settings - Fork 53
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
refactor: Index field directive #2994
refactor: Index field directive #2994
Conversation
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: Why can you not just use the same directive in both places? Do they have different arguments?
EDIT: They look like the have the same args, apart from fields
which is missing at the field level - can we please add support for field selection indexes defined at the field level and just have one directive?
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2994 +/- ##
===========================================
- Coverage 79.41% 79.41% -0.00%
===========================================
Files 329 329
Lines 25120 25133 +13
===========================================
+ Hits 19947 19957 +10
- Misses 3758 3762 +4
+ Partials 1415 1414 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 10 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
The arguments are of different types. The |
Yes, but can we not make them the same type? |
The direction cannot be implied the same way so you would have something confusing like this:
|
@AndrewSisley and I have come up with some potential improvements to the index directive. The input IndexIncludeArg{
field: String
direction: Ordering
} The Example of default direction:
would be equivelent to:
|
Collective decision was to go forward with this design but also allow defining the field orderings in |
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.
Production code looks good, but please test the new behaviour before merging.
func IndexFieldInputObject(orderingEnum *gql.Enum) *gql.InputObject { | ||
return gql.NewInputObject(gql.InputObjectConfig{ | ||
Name: "IndexField", | ||
Fields: gql.InputObjectConfigFieldMap{ |
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.
todo: Please add a Description, and note the implicit/explicit behaviour on it when attached to a field.
These descriptions are important and get rendered in the docs section and intellisense of GQL clients, and I guess that ORMs will also use them to document bound types.
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.
done
@@ -23,7 +23,7 @@ func TestIndexGet_ShouldReturnListOfExistingIndexes(t *testing.T) { | |||
Actions: []any{ |
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.
todo: (not necessarily in this file, this is just the first test file) Please add some integration tests testing implicit field level directives, the 'default' behaviour of the direction
property, the overriding of a default direction
by explicitly stating it in a field in includes
, the overriding of the field location by explicitly stating a field when the directive is hosted on a field, and composite indexes declared on a field.
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.
done
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! Thanks for taking care of this. I like the improvement to defining composite indexes and their components direction.
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, thanks Keenan!
Relevant issue(s)
Resolves #2926
Description
This PR fixes an issue where the index directive was defined twice.
The@index
field level directive has been renamed to@indexField
.The
fields
arg has been renamed toincludes
and is now a list of objects of type:The
direction
argument now sets the default direction of all fields in theincludes
list.When the index is used on a field definition and the field is not in the
includes
list it will be implicitly added.Tasks
How has this been tested?
Covered by existing tests.
Specify the platform(s) on which this was tested: