Skip to content

feat: pass DataFetcherEnvironment to arguments #173

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

Merged
merged 2 commits into from
Feb 25, 2019

Conversation

smyrick
Copy link
Contributor

@smyrick smyrick commented Feb 21, 2019

Clients can now specify DataFetchingEnvironment as one of their arguments. It will not be generated as part of the schema but will be passed down on execution and gives access to all the context of the query, parent fields and their arguments, and anything else that is on the graphql.schema.DataFetchingEnvironment

This is the example query I have added

@Component
class EnvironmentQuery : Query {
    fun nestedEnvironment(value: Int) = NestedNode(value)
}

data class NestedNode(
    val value: Int,
    val parentValue: Int? = null
) {
    fun nested(environment: DataFetchingEnvironment, value: Int): NestedNode {
        val parentValue: Int? = if (environment.executionStepInfo.hasParent()) environment.executionStepInfo.parent.getArgument("value") else null

        return NestedNode(value, parentValue)
    }

screen shot 2019-02-21 at 12 12 11 pm

@smyrick smyrick added type: enhancement New feature or request changes: minor Changes require a minor version labels Feb 21, 2019
@codecov
Copy link

codecov bot commented Feb 21, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@193871a). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #173   +/-   ##
=========================================
  Coverage          ?   98.14%           
  Complexity        ?      158           
=========================================
  Files             ?       55           
  Lines             ?      540           
  Branches          ?       93           
=========================================
  Hits              ?      530           
  Misses            ?        7           
  Partials          ?        3
Impacted Files Coverage Δ Complexity Δ
...dia/graphql/generator/types/FunctionTypeBuilder.kt 100% <100%> (ø) 11 <0> (?)
...m/expedia/graphql/execution/FunctionDataFetcher.kt 78.94% <100%> (ø) 10 <6> (?)
...aphql/generator/extensions/kParameterExtensions.kt 100% <100%> (ø) 0 <0> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 193871a...3d313be. Read the comment docs.

test: update test to fix detekt issues
@smyrick smyrick force-pushed the graphql-context-nested-inputs branch from 5d63302 to 3d313be Compare February 25, 2019 04:11
@smyrick
Copy link
Contributor Author

smyrick commented Feb 25, 2019

@brennantaylor Comments addressed

@dariuszkuc dariuszkuc merged commit 88c6eeb into ExpediaGroup:master Feb 25, 2019
@smyrick smyrick deleted the graphql-context-nested-inputs branch February 25, 2019 17:39
@smyrick smyrick mentioned this pull request May 31, 2019
dariuszkuc pushed a commit to dariuszkuc/graphql-kotlin that referenced this pull request Aug 5, 2022
* feat: pass DataFetcherEnvironment to arguments

test: update test to fix detekt issues

* address pr comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes: minor Changes require a minor version type: enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

3 participants