Skip to content

Commit

Permalink
Replace spaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro Garanzha committed Jan 16, 2019
1 parent e53b642 commit 3d752ea
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions generator/plugins/dataloader/templates/output_object_fields.gohtml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{{- /*gotype: github.com/EGT-Ukraine/go2gql/generator/plugins/graphql.RenderFieldsContext*/ -}}
{{ range $field := $.OutputObject.DataLoaderFields -}}
{{$.OutputObject.VariableName}}.AddFieldConfig("{{$field.Name}}", &{{gqlPkg}}.Field{
Name: "{{$field.Name}}",
Description: "",
Type: {{graphqlOutputLoaderTypeName $.ObjectContext $field}},
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
parent := p.Source.(*{{goType $.OutputObject.GoType}})
{{$.OutputObject.VariableName}}.AddFieldConfig("{{$field.Name}}", &{{gqlPkg}}.Field{
Name: "{{$field.Name}}",
Description: "",
Type: {{graphqlOutputLoaderTypeName $.ObjectContext $field}},
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
parent := p.Source.(*{{goType $.OutputObject.GoType}})

loaders := {{loadersPkg}}.GetDataLoadersFromContext(p.Context)
loaders := {{loadersPkg}}.GetDataLoadersFromContext(p.Context)

if loaders == nil {
return nil, errors.New("Data loaders not found in context. Call loaders.GetContextWithLoaders")
}
if loaders == nil {
return nil, errors.New("Data loaders not found in context. Call loaders.GetContextWithLoaders")
}

{{if $field.KeyFieldSlice}}
thunk := loaders.{{$field.DataLoaderName}}Loader.LoadAllThunk(parent.{{$field.NormalizedParentKeyFieldName}})
{{if $field.KeyFieldSlice}}
thunk := loaders.{{$field.DataLoaderName}}Loader.LoadAllThunk(parent.{{$field.NormalizedParentKeyFieldName}})

return func() (interface{}, error) {
var loaderErrors error
Expand All @@ -29,13 +29,13 @@

return result, loaderErrors
}, nil
{{else}}
thunk := loaders.{{$field.DataLoaderName}}Loader.LoadThunk(parent.{{$field.NormalizedParentKeyFieldName}})

return func() (interface{}, error) {
return thunk()
}, nil
{{end}}
},
})
{{else}}
thunk := loaders.{{$field.DataLoaderName}}Loader.LoadThunk(parent.{{$field.NormalizedParentKeyFieldName}})

return func() (interface{}, error) {
return thunk()
}, nil
{{end}}
},
})
{{ end -}}

0 comments on commit 3d752ea

Please sign in to comment.