Skip to content

Commit ac9616f

Browse files
committed
Revert ArgumentValue->FieldValue changes
See gh-1187 See gh-1190 See gh-1174
1 parent 179929a commit ac9616f

34 files changed

+105
-1181
lines changed

Diff for: spring-graphql-docs/modules/ROOT/pages/client.adoc

-41
Original file line numberDiff line numberDiff line change
@@ -393,47 +393,6 @@ include-code::UseInterceptor[tag=register,indent=0]
393393

394394

395395

396-
[[client.fieldvalue]]
397-
== `FieldValue`
398-
399-
By default, input types in GraphQL are nullable and optional, an input value (or any of its fields)
400-
can be set to the `null` literal, or not provided at all. This distinction is useful for
401-
partial updates with a mutation where the underlying data may also be, either set to
402-
`null` or not changed at all accordingly.
403-
404-
Similar to the xref:controllers.adoc#controllers.schema-mapping.fieldvalue[`FieldValue<T> support in controllers`],
405-
we can wrap an Input type with `FieldValue<T>` or use it at the level of class attributes on the client side.
406-
Given a `ProjectInput` class like:
407-
408-
include-code::ProjectInput[indent=0]
409-
410-
We can use our client to send a mutation request:
411-
412-
include-code::FieldValueClient[tag=fieldvalue,indent=0]
413-
414-
For this to work, the client must use Jackson for JSON (de)serialization and must be configured
415-
with the `org.springframework.graphql.client.json.GraphQlModule`.
416-
This can be registered manually on the underlying HTTP client like so:
417-
418-
include-code::FieldValueClient[tag=createclient,indent=0]
419-
420-
This `GraphQlModule` can be globally registered in Spring Boot applications by contributing it as a bean:
421-
422-
[source,java,indent=0,subs="verbatim,quotes"]
423-
----
424-
@Configuration
425-
public class GraphQlJsonConfiguration {
426-
427-
@Bean
428-
public GraphQLModule graphQLModule() {
429-
return new GraphQLModule();
430-
}
431-
432-
}
433-
----
434-
435-
436-
437396
[[client.dgsgraphqlclient]]
438397
== DGS Codegen
439398

Diff for: spring-graphql-docs/modules/ROOT/pages/controllers.adoc

+11-22
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ See xref:controllers.adoc#controllers.schema-mapping.argument[`@Argument`].
143143

144144
See xref:controllers.adoc#controllers.schema-mapping.argument[`@Argument`].
145145

146-
| `FieldValue`
146+
| `ArgumentValue`
147147
| For access to a named field argument bound to a higher-level, typed Object along
148148
with a flag to indicate if the input argument was omitted vs set to `null`.
149149

150-
See xref:controllers.adoc#controllers.schema-mapping.field-value[`FieldValue`].
150+
See xref:controllers.adoc#controllers.schema-mapping.argument-value[`ArgumentValue`].
151151

152152
| `@Arguments`
153153
| For access to all field arguments bound to a higher-level, typed Object.
@@ -403,8 +403,8 @@ specified in the annotation, or to the parameter name. For access to the full ar
403403
map, please use xref:controllers.adoc#controllers.schema-mapping.arguments[`@Arguments`] instead.
404404

405405

406-
[[controllers.schema-mapping.fieldvalue]]
407-
=== `FieldValue`
406+
[[controllers.schema-mapping.argument-value]]
407+
=== `ArgumentValue`
408408

409409
By default, input arguments in GraphQL are nullable and optional, which means an argument
410410
can be set to the `null` literal, or not provided at all. This distinction is useful for
@@ -414,7 +414,7 @@ there is no way to make such a distinction, because you would get `null` or an e
414414
`Optional` in both cases.
415415

416416
If you want to know not whether a value was not provided at all, you can declare an
417-
`FieldValue` method parameter, which is a simple container for the resulting value,
417+
`ArgumentValue` method parameter, which is a simple container for the resulting value,
418418
along with a flag to indicate whether the input argument was omitted altogether. You
419419
can use this instead of `@Argument`, in which case the argument name is determined from
420420
the method parameter name, or together with `@Argument` to specify the argument name.
@@ -426,31 +426,20 @@ For example:
426426
@Controller
427427
public class BookController {
428428
429-
@QueryMapping
430-
public List<Book> searchBook(@Argument String search, FieldValue<Genre> genre) {
431-
if (!genre.isOmitted()) {
432-
// genre has been set but might hold a "null" value
433-
Genre genreValue = genre.value();
434-
}
435-
}
436-
437429
@MutationMapping
438-
public void addBook(@Argument BookInput bookInput) {
439-
FieldValue<String> genre = bookInput.genre();
440-
genre.ifPresent(genre -> {
441-
//...
442-
});
430+
public void addBook(ArgumentValue<BookInput> bookInput) {
431+
if (!bookInput.isOmitted()) {
432+
BookInput value = bookInput.value();
433+
// ...
434+
}
443435
}
444436
}
445437
----
446438

447-
`FieldValue` is also supported as a field within the object structure of an `@Argument`
439+
`ArgumentValue` is also supported as a field within the object structure of an `@Argument`
448440
method parameter, either initialized via a constructor argument or via a setter, including
449441
as a field of an object nested at any level below the top level object.
450442

451-
This is also supported on the client side with a dedicated Jackson Module,
452-
see the xref:client.adoc#client.fieldvalue[`FieldValue` support for clients] section.
453-
454443

455444
[[controllers.schema-mapping.arguments]]
456445
=== `@Arguments`

Diff for: spring-graphql-docs/src/main/java/org/springframework/graphql/docs/client/fieldvalue/FieldValueClient.java

-66
This file was deleted.

Diff for: spring-graphql-docs/src/main/java/org/springframework/graphql/docs/client/fieldvalue/ProjectInput.java

-23
This file was deleted.

Diff for: spring-graphql/src/main/java/org/springframework/graphql/FieldValue.java

-172
This file was deleted.

0 commit comments

Comments
 (0)