func (c *connectionContext) IsExternallyManaged() bool {
	return c.embedsPaginationArgs() || c.ReturnsPageInfo
}
IsExternallyManaged returns true if the connection is managed by the FieldFunc's function
and not thunder.
package schemabuilder
import (
	"context"
	"encoding/base64"
	"errors"
	"fmt"
	"reflect"
	"sort"
	"github.com/samsarahq/thunder/graphql"
	"github.com/samsarahq/thunder/internal/filter"
	"golang.org/x/sync/errgroup"
)
type Connection struct {
	TotalCount int64
	Edges      []Edge
	PageInfo   PageInfo
}
var typeOfString = reflect.TypeOf("")
func (c *Connection) paginateManually(args PaginationArgs) error {
	var elemsAfter, elemsBefore bool
	c.Edges, elemsAfter, elemsBefore = applyCursorsToAllEdges(c.Edges, args.Before, args.After)
	c.PageInfo.HasNextPage = args.Before != nil && elemsAfter
	c.PageInfo.HasPrevPage = args.After != nil && elemsBefore
	if (safeInt64Ptr(args.First) < 0) || safeInt64Ptr(args.Last) < 0 {
		return graphql.NewClientError("first/last cannot be a negative integer")
	}
	if args.First != nil && args.Last != nil {
		return graphql.NewClientError("cannot use both first and last together")
	}
	if args.First != nil && len(c.Edges) > int(*args.First) {
		c.Edges = c.Edges[:int(*args.First)]
		c.PageInfo.HasNextPage = true
	}
	if args.Last != nil && len(c.Edges) > int(*args.Last) {
		c.Edges = c.Edges[len(c.Edges)-int(*args.Last):]
		c.PageInfo.HasPrevPage = true
	}
	return nil
}
func (c *Connection) setCursors() {
	if len(c.Edges) == 0 {
		return
	}
	c.PageInfo.EndCursor = c.Edges[len(c.Edges)-1].Cursor
	c.PageInfo.StartCursor = c.Edges[0].Cursor
}
func (c *Connection) externallySetPageInfo(info PaginationInfo) (err error) {
	c.PageInfo.HasNextPage = info.HasNextPage
	c.PageInfo.HasPrevPage = info.HasPrevPage
	c.TotalCount, err = info.TotalCount()
	return err
}
type PageInfo struct {
	HasNextPage bool
	EndCursor   string
	HasPrevPage bool
	StartCursor string
	Pages       []string
}
type Edge struct {
	Node   interface{}
	Cursor string
}
type ConnectionArgs struct {
	First *int64
	Last *int64
	After *string
	Before *string
	Args interface{}
	FilterText *string
	SortBy *string
	SortOrder *SortOrder
}
type PaginationArgs struct {
	First  *int64
	Last   *int64
	After  *string
	Before *string
	FilterText *string
	SortBy     *string
	SortOrder  *SortOrder
}
func (p PaginationArgs) limit() int {
	if p.First != nil {
		return int(*p.First)
	}
	if p.Last != nil {
		return int(*p.Last)
	}
	return 0
}
type PaginationInfo struct {
	TotalCountFunc func() int64
	HasNextPage    bool
	HasPrevPage    bool
}
func (i PaginationInfo) TotalCount() (int64, error) {
	if i.TotalCountFunc == nil {
		return 0, errors.New("must set TotalCountFunc on PaginationInfo")
	}
	return i.TotalCountFunc(), nil
}
func getTypeName(typ reflect.Type) string {
	if typ.Kind() == reflect.Ptr {
		return typ.Elem().Name()
	}
	return fmt.Sprintf("NonNull%s", typ.Name())
}
type connectionContext struct {
	*funcContext
	Key string
	ReturnsPageInfo bool
	PaginationArgsIndex int
	FilterTextFields map[string]*graphql.Field
	SortFields map[string]*graphql.Field
	SortFunctions map[string]func([]sortReference, SortOrder)
}
func (c *connectionContext) embedsPaginationArgs() bool {
	return c.PaginationArgsIndex != -1
}