Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to OperationContext and remove duplicate fields to fix https:… #1189

Merged
merged 1 commit into from
Jun 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions docs/content/reference/field-collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,21 @@ The type `Circle` would satisfy `Circle`, `Shape`, and `Shapes` — these values
Say we have the following GraphQL query

```graphql
flowBlocks {
id
block{
id
title
type
choices{
id
title
description
slug
}
}
query {
flowBlocks {
id
block {
id
title
type
choices {
id
title
description
slug
}
}
}
}
```

Expand All @@ -83,19 +85,17 @@ Here is an example which get's all requested field as convenient string slice, w
```golang
func GetPreloads(ctx context.Context) []string {
return GetNestedPreloads(
graphql.GetRequestContext(ctx),
graphql.GetOperationContext(ctx),
graphql.CollectFieldsCtx(ctx, nil),
"",
)
}

func GetNestedPreloads(ctx *graphql.RequestContext, fields []graphql.CollectedField, prefix string) (preloads []string) {
func GetNestedPreloads(ctx *graphql.OperationContext, fields []graphql.CollectedField, prefix string) (preloads []string) {
for _, column := range fields {
prefixColumn := GetPreloadString(prefix, column.Name)
preloads = append(preloads, prefixColumn)
preloads = append(preloads, GetNestedPreloads(ctx, graphql.CollectFields(ctx, column.SelectionSet, nil), prefixColumn)...)
preloads = append(preloads, GetNestedPreloads(ctx, graphql.CollectFields(ctx, column.Selections, nil), prefixColumn)...)

}
return
}
Expand Down