Skip to content

Commit

Permalink
entgql: fixed edge filter
Browse files Browse the repository at this point in the history
Co-authored-by: Amr Tamimi <amrnt0@gmail.com>
  • Loading branch information
giautm and Amr Tamimi committed Jun 27, 2022
1 parent 76ba448 commit a97f9a0
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
8 changes: 6 additions & 2 deletions entgql/internal/todo/ent/gql_edge.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions entgql/internal/todogotype/ent/gql_edge.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions entgql/internal/todopulid/ent/gql_edge.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions entgql/internal/todouuid/ent/gql_edge.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions entgql/template/edge.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,19 @@ import "context"
{{- if and (hasTemplate "gql_where_input") (hasWhereInput $e) }}where *{{ $whereInput }},{{ end }}
opts ...{{ $opt }},
) (*{{ $conn }}, error) {
{{- if orderFields $e.Type }}
opts = append(opts, {{ print "With" $order }}(orderBy))
{{- end }}
{{- if and (hasTemplate "gql_where_input") (hasWhereInput $e) }}
opts = append(opts, {{ print "With" $names.Node "Filter" }}(where.Filter))
{{- end }}
{{- /* May be nil if the totalCount was not loaded. */}}
totalCount := {{ $r }}.Edges.totalCount[{{ $i }}]
if nodes, err := {{ $r }}.Edges.{{ $e.StructField }}OrErr(); err == nil {
conn := &{{ $conn }}{Edges: []*{{ $edge }}{}}
if totalCount != nil {
conn.TotalCount = *totalCount
}
{{- if orderFields $e.Type }}
opts = append(opts, {{ print "With" $order }}(orderBy))
{{- end }}
pager, err := {{ $newPager }}(opts)
if err != nil {
return nil, err
Expand Down

0 comments on commit a97f9a0

Please sign in to comment.