Skip to content

feat: support data and errors with DataFetcherResult #245

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

Closed
wants to merge 56 commits into from

Conversation

smyrick
Copy link
Contributor

@smyrick smyrick commented Jun 26, 2019

Fixes #244

Kotlin functions can now return a DataFetcherResult instead of just their return type which allows you to modify the errors field with any extra data you need

@smyrick smyrick added type: enhancement New feature or request changes: minor Changes require a minor version labels Jun 26, 2019
@smyrick smyrick marked this pull request as ready for review June 26, 2019 17:47
@ExpediaGroup ExpediaGroup deleted a comment from codecov bot Jun 26, 2019
@dariuszkuc
Copy link
Collaborator

While this could work it would also kind of imply that you would want to explicitly return DataFetcherResult pretty much everywhere. Would it be possible to support it in more generic way?

@smyrick
Copy link
Contributor Author

smyrick commented Jun 26, 2019

@dkuc84 What would be that more generic way? Do you mean some additional option to add info into the errors field but without wrapping?

I briefly looked into this. Is there some argument that we can include in the data fetchers or from the DataFetchingEnvironmnet that allows you to modify the errors? I haven't seen anything so far: https://www.graphql-java.com/documentation/v13/data-fetching/

Fixes ExpediaGroup#244

Kotlin functions can now return a  instead of just their return type which allows you to modify the errors field with any extra data you need
@smyrick smyrick force-pushed the data-errors-result branch from cdd20ba to 202e19e Compare June 28, 2019 18:11
@ExpediaGroup ExpediaGroup deleted a comment from codecov bot Jun 28, 2019
@codecov
Copy link

codecov bot commented Jun 28, 2019

Codecov Report

Merging #245 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #245      +/-   ##
============================================
+ Coverage     96.87%   96.88%   +<.01%     
- Complexity      193      194       +1     
============================================
  Files            59       59              
  Lines           641      643       +2     
  Branches        116      117       +1     
============================================
+ Hits            621      623       +2     
  Misses            9        9              
  Partials         11       11
Impacted Files Coverage Δ Complexity Δ
...expedia/graphql/generator/types/FunctionBuilder.kt 100% <100%> (ø) 14 <0> (+1) ⬆️

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 1d00b99...202e19e. Read the comment docs.

@dariuszkuc
Copy link
Collaborator

I'm thinking we could do something around adding errors to the GraphQL context but that would also imply we would need to either add some instrumentation to populate errors (workaround) or re-implement execution logic so it would take that into account.

@smyrick
Copy link
Contributor Author

smyrick commented Jul 15, 2019

I am going to close this PR until we have a solid decision on how we want to support data and errors. Please add more comments to the issue #244

@smyrick smyrick closed this Jul 15, 2019
@smyrick smyrick deleted the data-errors-result branch July 15, 2019 18:14
@smyrick smyrick restored the data-errors-result branch September 11, 2019 19:23
@smyrick smyrick reopened this Sep 11, 2019
@codecov-io
Copy link

Codecov Report

Merging #245 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #245      +/-   ##
============================================
+ Coverage     96.87%   96.88%   +<.01%     
- Complexity      193      194       +1     
============================================
  Files            59       59              
  Lines           641      643       +2     
  Branches        116      117       +1     
============================================
+ Hits            621      623       +2     
  Misses            9        9              
  Partials         11       11
Impacted Files Coverage Δ Complexity Δ
...expedia/graphql/generator/types/FunctionBuilder.kt 100% <100%> (ø) 14 <0> (+1) ⬆️

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 1d00b99...202e19e. Read the comment docs.

dariuszkuc and others added 13 commits September 11, 2019 12:25
…#247)

* Explicit support for deprecated directive in the schema

* custom SDL printer

* customize schema print extension, fix unit tests and detekt

* add printer tests

* revert changes to GraphQLName
There are use cases when directives could be just informational (e.g. @deprecated). Instead of defining no-op directive wiring we should just ignore directives without wiring.
* update library structure

Changes to a multi module project with `graphql-kotlin-schema-generator` (previously released as `graphql-kotlin`) and `graphql-kotlin-spring-example` (previously standalone project).

* fix travis build

* update README to reflect new structure

* skip generating javadoc for example app
Set the profiles for release and javadoc to only run on the schema-generator module as the example app doesn't need to be published
…Group#269)

Additional configuration fixes:
* remove maven-javadoc-plugin as dokka already genertes the javadoc jar
* explicitly disable maven-deploy-plugin as we are using nexus-staging-maven-plugin with explicit config
* skip generating sources for the example app
tobias-f and others added 12 commits September 11, 2019 12:28
ExpediaGroup#304)

* Changes to sdl field of _service object to make it compliant with the federation specification

- if the Query type is present, it should have the @extends directive, since it extends the query type
- the default schema definition should not be included in the sdl
- empty queries should not be present in the SDL
…p#306)

* feature: batch support for resolving federation requests

NOTE: This is a non-backwards compatible change as FederatedTypeResolver resolve signature is changed to process list of representations at once. This allows resolver to either instantiate entities one by one or use some batch logic.

Update _entities query resolver logic to resolve federation requests in batch mode. Specified federated object representations are grouped by the underlying typename and asynchronously resolved in batches. Batch results are then merged into a single list that preserves the original order of entities. If entity cannot be resolved, NULL will be returned instead. Any exceptions thrown while attempting to resolve the federated types will be returned together with partially resolved data.

* additional test for invalid result size
* Update badges

* Remove top level javadoc badge
* Start a federation example

Requires an update from graphql-java first graphql-java/graphql-java#1644

* fix federation example

* exclude federation example from code coverage

* Move to top-level examples folder
Fixes ExpediaGroup#249
Fixes ExpediaGroup#318

Resolve the two bugs and refactor the function to its own ArgumentBuilder so we can more easily test the bugs
Fixes ExpediaGroup#278

Property (input/output) directives are now resolved by checking the property and the constructor argument for any directives. This is the same pattern for checking any other annotations we have
Fixes ExpediaGroup#310

While I don't think it is possible to have an input type extended we should still be able to have nested types that are not part of the federated entities be generated properly. This can happen when there are lists of nullalbes or double wrapped elements
@dariuszkuc
Copy link
Collaborator

@smyrick is this going to work with monads (e.g. CompletableFuture)?

Fixes ExpediaGroup#325

I will update the tokens in Travis before we merge
Clean up the README and add CONTRIBUTING docs to prepare for the 1.0.0 release
Add more unit tests and remove duplicate default values to increase code coverage
Update the Maven settings of contributors to the EG Open Source email and name
* Add copyright header

* Update copyright name
* Github action for PR check

* Update maven.yml
* Fix the copyright header

Per this PR, legal wants the company name to remain Expedia, Inc ExpediaGroup/new-project#3

* Update package.json license
@smyrick smyrick closed this Sep 11, 2019
@smyrick smyrick deleted the data-errors-result branch September 11, 2019 19:36
smyrick pushed a commit to smyrick/graphql-kotlin that referenced this pull request Sep 11, 2019
Fixes ExpediaGroup#244
Rebase of ExpediaGroup#245

Kotlin functions can now return a DataFetcherResult instead of just their return type which allows you to modify the errors field with any extra data you need
dariuszkuc pushed a commit that referenced this pull request Sep 13, 2019
* Allow data and errors to be returned with DataFetcherResult

Fixes #244
Rebase of #245

Kotlin functions can now return a DataFetcherResult instead of just their return type which allows you to modify the errors field with any extra data you need

* Move output type monad code into the generator

* Move unwrapping logic back to function builder

* Add unit test for publisher implementation
dariuszkuc pushed a commit to dariuszkuc/graphql-kotlin that referenced this pull request Aug 5, 2022
…roup#342)

* Allow data and errors to be returned with DataFetcherResult

Fixes ExpediaGroup#244
Rebase of ExpediaGroup#245

Kotlin functions can now return a DataFetcherResult instead of just their return type which allows you to modify the errors field with any extra data you need

* Move output type monad code into the generator

* Move unwrapping logic back to function builder

* Add unit test for publisher implementation
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.

Return both data and errors/partial response
5 participants