github.com/senomas/gqlgen@v0.17.11-0.20220626120754-9aee61b0716a/plugin/resolvergen/resolver.gotpl (about)

     1  {{ reserveImport "context"  }}
     2  {{ reserveImport "fmt"  }}
     3  {{ reserveImport "io"  }}
     4  {{ reserveImport "strconv"  }}
     5  {{ reserveImport "time"  }}
     6  {{ reserveImport "sync"  }}
     7  {{ reserveImport "errors"  }}
     8  {{ reserveImport "bytes"  }}
     9  
    10  {{ reserveImport "github.com/vektah/gqlparser/v2" }}
    11  {{ reserveImport "github.com/vektah/gqlparser/v2/ast" }}
    12  {{ reserveImport "github.com/99designs/gqlgen/graphql" }}
    13  {{ reserveImport "github.com/99designs/gqlgen/graphql/introspection" }}
    14  
    15  {{ .Imports }}
    16  
    17  {{ if .HasRoot }}
    18  	type {{.ResolverType}} struct {}
    19  {{ end }}
    20  
    21  {{ range $resolver := .Resolvers -}}
    22  	func (r *{{lcFirst $resolver.Object.Name}}{{ucFirst $.ResolverType}}) {{$resolver.Field.GoFieldName}}{{ $resolver.Field.ShortResolverDeclaration }} {
    23  		{{ $resolver.Implementation }}
    24  	}
    25  
    26  {{ end }}
    27  
    28  {{ range $object := .Objects -}}
    29  	// {{ucFirst $object.Name}} returns {{ $object.ResolverInterface | ref }} implementation.
    30  	func (r *{{$.ResolverType}}) {{ucFirst $object.Name}}() {{ $object.ResolverInterface | ref }} { return &{{lcFirst $object.Name}}{{ucFirst $.ResolverType}}{r} }
    31  {{ end }}
    32  
    33  {{ range $object := .Objects -}}
    34  	type {{lcFirst $object.Name}}{{ucFirst $.ResolverType}} struct { *{{$.ResolverType}} }
    35  {{ end }}
    36  
    37  {{ if (ne .RemainingSource "") }}
    38      // !!! WARNING !!!
    39      // The code below was going to be deleted when updating resolvers. It has been copied here so you have
    40      // one last chance to move it out of harms way if you want. There are two reasons this happens:
    41  	//  - When renaming or deleting a resolver the old code will be put in here. You can safely delete
    42  	//    it when you're done.
    43  	//  - You have helper methods in this file. Move them out to keep these resolver files clean.
    44  	{{ .RemainingSource }}
    45  {{ end }}