-
Notifications
You must be signed in to change notification settings - Fork 305
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
Update documentation with guidance on the use of aggregates and projections with Spring Data #264
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found some points that may need to be looked after
Regarding operation
instead of query
:
https://spec.graphql.org/draft/#sel-FAFRHABAB3Bw0O
There are three types of operations that GraphQL models:
query – [...]
mutation – [...]
subscription – [...]
Query is extra confusing because we are talking about database interactions in this section ("... that translates GraphQL queries into SQL or a JSON query" for example)
|
||
Sometimes, an already reduced set of fields can be useful when exposing data. Also, some | ||
arrangements might require transformations to be applied before data is returned for a | ||
GraphQL query. Spring Data supports for these scenarios projections: Interface and DTO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GraphQL query. Spring Data supports for these scenarios projections: Interface and DTO | |
GraphQL operation. Spring Data supports for these scenarios projections: Interface and DTO |
Projections. | ||
|
||
Interface projections define a fixed set of properties to expose. Properties may or may | ||
not be `null`, depending on the query result. A plain, https://docs.spring.io/spring-data/commons/docs/current/reference/html/#projections.interfaces.closed[closed interface projection] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not be `null`, depending on the query result. A plain, https://docs.spring.io/spring-data/commons/docs/current/reference/html/#projections.interfaces.closed[closed interface projection] | |
not be `null`, depending on the operation result. A plain, https://docs.spring.io/spring-data/commons/docs/current/reference/html/#projections.interfaces.closed[closed interface projection] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
query is here the database query.
DTO projections materialize from a query where the individual projections are | ||
determined by the projection itself. DTO projections are commonly used with full-args | ||
constructors (e.g. Java Records) and therefore they can be only constructed if all | ||
required fields (or columns) are part of the query result. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DTO projections materialize from a query where the individual projections are | |
determined by the projection itself. DTO projections are commonly used with full-args | |
constructors (e.g. Java Records) and therefore they can be only constructed if all | |
required fields (or columns) are part of the query result. | |
DTO projections materialize from a GraphQL operation, where the individual projections are | |
determined by the projection itself. DTO projections are commonly used with full-args | |
constructors (e.g. Java records) and therefore they can only be constructed if all | |
required fields (or columns) are part of the operation result. |
This paragraph reads a bit confusingly for me, what does it mean exactly?
where the individual projections are determined by the projection itself
required fields (or columns) are part of the operation/query result
- should this be the operation's selection set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
query is here the database query.
individual projections are
should be individual properties are
The advantage of using aggregates is that you do not require additional code to expose | ||
data through repositories. When processing a query, the integration layer transforms the | ||
query selection into property paths. It provides these hints of which properties to | ||
materialize to the underlying Spring Data module that limits the field (or column) selection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The advantage of using aggregates is that you do not require additional code to expose | |
data through repositories. When processing a query, the integration layer transforms the | |
query selection into property paths. It provides these hints of which properties to | |
materialize to the underlying Spring Data module that limits the field (or column) selection. | |
The advantage of using aggregates is that you do not require additional code to expose | |
data through repositories. When processing a GraphQL operation, the integration layer transforms the | |
operation's selection set into property paths. It provides these hints of which properties to | |
materialize to the underlying Spring Data module that limits the field (or column) selection. |
@@ -480,6 +480,57 @@ assertThat(books.get(0).getName()).isEqualTo("..."); | |||
[[data]] | |||
== Data Integration | |||
|
|||
Spring for GraphQL is, in contrast to other GraphQL technologies that surface persistent | |||
data, not a data gateway that translates GraphQL queries into SQL or a JSON query. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data, not a data gateway that translates GraphQL queries into SQL or a JSON query. | |
data, not a data gateway that translates GraphQL queries into SQL, or JSON queries. |
With Spring Data you can chose whether you want to let your aggregate participate as | ||
underlying data model directly to be exposed as GraphQL result or whether you want to | ||
apply projections to your data model before returning it as GraphQL query result. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With Spring Data you can chose whether you want to let your aggregate participate as | |
underlying data model directly to be exposed as GraphQL result or whether you want to | |
apply projections to your data model before returning it as GraphQL query result. | |
With Spring Data you can choose whether you want to let your aggregate participate as | |
an underlying data model to be directly exposed as a GraphQL result, or whether you want to | |
apply projections to your data model before returning it as a GraphQL operation result. |
Closes gh-248