From 6518d8391acf8618b1c39539b9bb7306814898d3 Mon Sep 17 00:00:00 2001 From: Richard Lindhout Date: Mon, 11 May 2020 23:17:18 +0200 Subject: [PATCH] Upgrade to OperationContext and remove duplicate fields to fix https://github.com/99designs/gqlgen/pull/1161 --- docs/content/reference/field-collection.md | 34 +++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/content/reference/field-collection.md b/docs/content/reference/field-collection.md index 0a065256a2..c6cd8ba995 100644 --- a/docs/content/reference/field-collection.md +++ b/docs/content/reference/field-collection.md @@ -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 + } + } + } } ``` @@ -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 }