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

Provide consistent support for dynamically registered DataFetchers #1770

Merged
merged 12 commits into from
Jan 29, 2024

Conversation

ivanasen
Copy link
Contributor

@ivanasen ivanasen commented Jan 8, 2024

Pull request checklist

  • Please read our contributor guide
  • Consider creating a discussion on the discussion forum
    first
  • Make sure the PR doesn't introduce backward compatibility issues
  • Make sure to have sufficient test cases

Pull Request type

  • Bugfix
  • Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Other (please describe):

Changes in this PR

Implemented a new way of using @DgsCodeRegistry in which a DgsCodeRegistryBuilder is injected instead. This way, the registered DataFetchers are processed by DataFetcherResultProcessors and the behavior is more consistent with the annotation-based approach.

Link to discussion

Alternatives considered

Haven't considered alternatives.

ivanasen added 3 commits January 9, 2024 00:11
Implemented a new way of using `@DgsCodeRegistry` in which
a `DgsCodeRegistryBuilder` is injected instead. This way,
the registered DataFetchers are processed by DataFetcherResultProcessors
and the behaviour is more consistent with the annotation-based
approach.

[Link to discussion](Netflix#1768)
Copy link
Contributor

@srinivasankavitha srinivasankavitha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR contribution. Changes look good, just had a few comments.

@@ -477,29 +481,66 @@ internal class DgsSchemaProviderTest {
val coordinates = FieldCoordinates.coordinates("Query", "myField")
return codeRegistryBuilder.dataFetcher(coordinates, df)
}

// Result should be processed by DataFetcherResultProcessors
@DgsCodeRegistry
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be able to also update our docs to use the DgsCodeRegistryBuilder? Much appreciated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, where are the docs 😄 ?

@ivanasen
Copy link
Contributor Author

ivanasen commented Jan 9, 2024

I was looking at the code today in DgsSchemaProvider.kt and I actually think that in order to really be consistent we need to not account for only the DataFetcherResultProcessors in the new DgsCodeRegistryBuilder . In order for it to be really consistent, shouldn't we account for most of the logic in DgsSchemaProvider::registerDataFetcher? Also, I shouldn't be duplicating logic here. Registering DataFetchers through annotations and dynamically should use common logic. So in that case, we should refactor out the DgsSchemaProvider::registerDataFetcher (or most parts of it) in some common place which can be invoked from both DgsSchemaProvider and DgsCodeRegistryBuilder.

I won't have time to make this change in the next 2-3 days, but will most likely get to it in the weekend

@srinivasankavitha
Copy link
Contributor

I was looking at the code today in DgsSchemaProvider.kt and I actually think that in order to really be consistent we need to not account for only the DataFetcherResultProcessors in the new DgsCodeRegistryBuilder . In order for it to be really consistent, shouldn't we account for most of the logic in DgsSchemaProvider::registerDataFetcher? Also, I shouldn't be duplicating logic here. Registering DataFetchers through annotations and dynamically should use common logic. So in that case, we should refactor out the DgsSchemaProvider::registerDataFetcher (or most parts of it) in some common place which can be invoked from both DgsSchemaProvider and DgsCodeRegistryBuilder.

I won't have time to make this change in the next 2-3 days, but will most likely get to it in the weekend

Ok. I don't mind the current solution in any case. It's really not much duplication.

@ivanasen
Copy link
Contributor Author

I was looking at the code today in DgsSchemaProvider.kt and I actually think that in order to really be consistent we need to not account for only the DataFetcherResultProcessors in the new DgsCodeRegistryBuilder . In order for it to be really consistent, shouldn't we account for most of the logic in DgsSchemaProvider::registerDataFetcher? Also, I shouldn't be duplicating logic here. Registering DataFetchers through annotations and dynamically should use common logic. So in that case, we should refactor out the DgsSchemaProvider::registerDataFetcher (or most parts of it) in some common place which can be invoked from both DgsSchemaProvider and DgsCodeRegistryBuilder.
I won't have time to make this change in the next 2-3 days, but will most likely get to it in the weekend

Ok. I don't mind the current solution in any case. It's really not much duplication.

Ok, if I'm gonna make more changes better make them in pieces. For this commit, I propose we just handle this.

@srinivasankavitha
Copy link
Contributor

I was looking at the code today in DgsSchemaProvider.kt and I actually think that in order to really be consistent we need to not account for only the DataFetcherResultProcessors in the new DgsCodeRegistryBuilder . In order for it to be really consistent, shouldn't we account for most of the logic in DgsSchemaProvider::registerDataFetcher? Also, I shouldn't be duplicating logic here. Registering DataFetchers through annotations and dynamically should use common logic. So in that case, we should refactor out the DgsSchemaProvider::registerDataFetcher (or most parts of it) in some common place which can be invoked from both DgsSchemaProvider and DgsCodeRegistryBuilder.
I won't have time to make this change in the next 2-3 days, but will most likely get to it in the weekend

Ok. I don't mind the current solution in any case. It's really not much duplication.

Ok, if I'm gonna make more changes better make them in pieces. For this commit, I propose we just handle this.

Sounds good. @kilink - any objections to merging this PR?

@kilink
Copy link
Member

kilink commented Jan 17, 2024

I was looking at the code today in DgsSchemaProvider.kt and I actually think that in order to really be consistent we need to not account for only the DataFetcherResultProcessors in the new DgsCodeRegistryBuilder . In order for it to be really consistent, shouldn't we account for most of the logic in DgsSchemaProvider::registerDataFetcher? Also, I shouldn't be duplicating logic here. Registering DataFetchers through annotations and dynamically should use common logic. So in that case, we should refactor out the DgsSchemaProvider::registerDataFetcher (or most parts of it) in some common place which can be invoked from both DgsSchemaProvider and DgsCodeRegistryBuilder.
I won't have time to make this change in the next 2-3 days, but will most likely get to it in the weekend

Ok. I don't mind the current solution in any case. It's really not much duplication.

Ok, if I'm gonna make more changes better make them in pieces. For this commit, I propose we just handle this.

Sounds good. @kilink - any objections to merging this PR?

LGTM, just had 2 minor comments about nullability of parameters.

@ivanasen
Copy link
Contributor Author

ivanasen commented Jan 20, 2024

Thanks, I updated the PR with the suggested changes. I haven't received an answer to this question though

@srinivasankavitha
Copy link
Contributor

srinivasankavitha commented Jan 22, 2024

Thanks, I updated the PR with the suggested changes. I haven't received an answer to this question though

Think we decided to keep things as is for now. We can do a refactor in a separate PR in the future, but I'm also fine leaving things the way they are for now.

The branch has some conflicts. If you could resolve them when you have a chance, we'll go ahead and merge the PR. Thanks for all the work on the PR!

@srinivasankavitha srinivasankavitha merged commit 0b0f41d into Netflix:master Jan 29, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants