-
Notifications
You must be signed in to change notification settings - Fork 116
Make pagination an option for FieldFunc #197
Conversation
Pull Request Test Coverage Report for Build 1205
💛 - Coveralls |
Name: name, | ||
Fn: f, | ||
}) | ||
o.FieldFunc(name, f, Paginated) |
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.
This uses the new API under the hood now
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.
love it
@@ -914,21 +912,22 @@ func (sb *schemaBuilder) buildStruct(typ reflect.Type) error { | |||
for _, name := range names { | |||
method := methods[name] | |||
|
|||
if method.Paginated { |
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'm fine with this having separate code paths for now
|
||
// NonNullable is an option that can be passed to a FieldFunc to indicate that | ||
// its return value is required, even if the return value is a pointer type. | ||
func NonNullable(m *method) { | ||
var NonNullable fieldFuncOptionFunc = func(m *method) { |
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.
This is a kinda cute pattern 😄
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.
too cute
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.
maybe a quick example in the commit message for what the more complicated case will look like is useful.
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.
Added
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.
Looks awesome! Can we add a changelog note?
@@ -85,6 +90,9 @@ func (s *Object) Key(f string) { | |||
type method struct { | |||
MarkedNonNullable bool | |||
Fn interface{} | |||
|
|||
// Connection configuration |
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.
? Is this meant as a header for the section?
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.
Yeah - I can remove it for now if it's confusing
ad3ee8b
to
e51a366
Compare
This is in preparation for some more complex options we will be introducing as part of our pagination work. eg: // thunder/graphql/... type PaginationSort map[string]interface{} // someone using thunder can pass in any option: schema.FieldFunc(ctx, getPaginatedResource, Pagination) schema.FieldFunc(ctx, getPaginatedResource, PaginationSort{ "groupName": func(ctx, resource) string { return "theGroupName" } }) // and doesn't have to do this: schema.FieldFunc(ctx, getPaginatedResource, PaginationSort{ ... }.Option)
e51a366
to
5fbcc74
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.
great
Don't require PaginateFieldFunc for creating field funcs. Rather, FieldFunc takes in a Paginate option.