Skip to content

Add support for projected payloads #202

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 1 commit into from

Conversation

mp911de
Copy link
Member

@mp911de mp911de commented Nov 26, 2021

Controller methods now accept interface projections for individual or all
request arguments when Spring Data is on the classpath.

Closes gh-197

Controller methods now accept interface projections for individual or all
request arguments when Spring Data is on the class path.
@andimarek
Copy link
Contributor

andimarek commented Nov 26, 2021

I want to point out that argument values are coerced by GraphQL Java before made accessible via DataFetchingEnvironment. This means for custom Scalars coercing is basically a competing mechanism to HandlerMethodArgumentResolver in some way.

For example:

{ search(input: {foo: "bar", foo2: 1233}} }

for this schema:

scalar MyInputScalar
type Query {
  search(input: MyInputScalar): String
}

I can implement MyInputScalar in a way which returns for example a SearchValue object which can be anything.

I think that is an edge case, but I want to highlight it anyway. cc @rstoyanchev

@rstoyanchev rstoyanchev added in: core Issues related to config and core support type: enhancement A general enhancement labels Dec 1, 2021
@rstoyanchev rstoyanchev added this to the 1.0.0-M4 milestone Dec 1, 2021
@rstoyanchev
Copy link
Contributor

rstoyanchev commented Dec 1, 2021

@andimarek, a HandlerMethodArgumentResolver is just a contract which can be used to implement support for extracting anything from DataFetchingEnvironment and injecting that into a controller method. In that sense, it's not inherently competing with custom scalars. It depends on the specifics of how a resolver is implemented.

Keep in mind that for M3, we changed how an @Argument annotated method parameter is resolved, to use the values in the DataFetchingEnvironment#getArguments() map and apply them to properties of the target object. This was specifically meant to ensure we respect such custom scalars that have already been deserialized by GraphQL Java. You can see #122 for that.

The ProjectedPayloadMethodArgumentResolver added in this PR also works by looking up values in the DataFetchingEnvironment#getArguments() map so that should be okay too, as far as I can see.

rstoyanchev pushed a commit that referenced this pull request Dec 1, 2021
Controller methods now accept interface projections for individual or all
request arguments when Spring Data is on the class path.

See gh-202
rstoyanchev added a commit that referenced this pull request Dec 1, 2021
The convert method in ArgumentMethodArgumentResolver is gone and in any
case ProjectedPayloadMethodArgumentResolver mainly needs to know the
name of the argument if an Argument annotation is present.

See gh-202
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues related to config and core support type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for projected payload in controller methods
3 participants