-
Notifications
You must be signed in to change notification settings - Fork 0
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
graphql #50
Conversation
@@ -43,4 +54,69 @@ public WebClient.Builder webClient() { | |||
return WebClient.builder(); | |||
} | |||
|
|||
public GraphQLScalarType localDateTimeScalar() { |
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.
@eyakauleva try to make more elegant solution here
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.
done 679c337
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class ExceptionResolver extends DataFetcherExceptionResolverAdapter { |
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.
@eyakauleva nice solution
since GraphQL always throws 200
HTTP status code it's very inconvenient to show errors to the end user
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.
@h1alexbel GraphQL still returns 200 HTTP status code. This resolver sets status code only as a field to a response body and also sets custom error message there.
As I found out, it's a GraphQL standard to always return 200 OK in such cases, cause non-200 response codes indicate that some issue occurred at the HTTP transport layer, not the GraphQL layer.
So I'm not sure whether it's a good practice to replace GraphQL HTTP status code and whether it's possible at all.
|
||
@MutationMapping("createUser") | ||
public Mono<EsUser> create(@Argument final User user) { | ||
CreateUserCommand command = new CreateUserCommand(user, "Liza123"); |
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.
@eyakauleva what is the "Liza123"
?
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.
fixed 679c337
}).build(); | ||
} | ||
|
||
public ValidationSchemaWiring schemaWiring() { |
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.
@eyakauleva as far I understand this ValidationSchemaWiring also should be represented as Spring Bean
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.
@h1alexbel I call this method in another method, then why it should be a bean?
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.
@eyakauleva for code reuse?
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.
@h1alexbel but I call this method only once
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.
@eyakauleva I know, but what about future usages?
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.
@h1alexbel according to YAGNI principle features should only be added when required
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.
@eyakauleva YAGNI is about features or FR, not about maintainability, which is NFR
try to design all your classes, methods, functions with maintainability in mind
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.
done 679c337
|
||
@MutationMapping("deleteUser") | ||
public Mono<EsUser> delete(@Argument final String id) { | ||
DeleteUserCommand command = new DeleteUserCommand(id, "Liza123"); |
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.
@eyakauleva the same goes here
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.
fixed 679c337
close #49