Skip to content

Commit f89c0c3

Browse files
committed
Blog on DataFetcherResult PR comments - better titling
1 parent 11acec8 commit f89c0c3

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

content/blog/deep-dive-data-fetcher-results.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
+++
2-
title = "graphql-java - In Depth - Part 1: DataFetcherResult"
2+
title = "Building efficient data fetchers by looking ahead"
33
author = "Brad Baker"
44
tags = []
55
categories = []
66
date = 2019-04-11T00:00:00+10:00
77
+++
88

9-
# DataFetcherResult
9+
# Efficient data fetchers
1010

11-
Today we are looking into the `graphql.execution.DataFetcherResult` object.
11+
Today we are looking into the `graphql.schema.DataFetchingFieldSelectionSet` and `graphql.execution.DataFetcherResult` objects as means
12+
to build efficient data fetchers.
1213

1314
# The scenario
1415

@@ -31,16 +32,16 @@ But first lets set the scene. Imagine we have a system that can return `issues`
3132
Nominally we would have a `graphql.schema.DataFetcher` on `issues` that returns a list of issues and one on the field `comments` that returns the list of comments
3233
for each issue `source` object.
3334

34-
As you can see this naively creates an N+1 problem where we need to fetch data multiple times, one for each `issue` object in isolation.
35+
As you can see this naively creates an *N+1 problem* where we need to fetch data multiple times, one for each `issue` object in isolation.
3536

3637
We could attack this using the `org.dataloader.DataLoader` pattern but there is another way which will discuss in this article.
3738

38-
# Look ahead
39+
# Look ahead via DataFetchingFieldSelectionSet
3940

4041
The data fetcher behind the `issues` field is able to look ahead and see what sub fields are being asked for. In this case it knows that `comments` are being asked
4142
for and hence it could prefetch them at the same time.
4243

43-
`graphql.schema.DataFetchingEnvironment#getSelectionSet` can be used by data fetcher code to get the selection set of fields for a given parent field.
44+
`graphql.schema.DataFetchingEnvironment#getSelectionSet` (aka `graphql.schema.DataFetchingFieldSelectionSet`) can be used by data fetcher code to get the selection set of fields for a given parent field.
4445

4546
{{< highlight Java "linenos=table" >}}
4647
DataFetcher issueDataFetcher = environment -> {

0 commit comments

Comments
 (0)