Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upHave a default context object included in graphql-java #1313
Conversation
| public Builder context(Object context) { | ||
| this.context = context; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder context(GraphQLContext.Builder contextBuilder) { |
tsroka
Nov 13, 2018
Member
This function does not look very useful. Is that a convention in gql-java to accept builders?
This function does not look very useful. Is that a convention in gql-java to accept builders?
bbakerman
Nov 15, 2018
Author
Member
yes it is - we could get rid of it I guess but we do this in other places
yes it is - we could get rid of it I guess but we do this in other places
| */ | ||
| @PublicApi | ||
| @SuppressWarnings("unchecked") | ||
| public class GraphQLContext { |
tsroka
Nov 13, 2018
Member
maybe annotate with ThreadSafe? Or add comment that it is thread safe?
maybe annotate with ThreadSafe? Or add comment that it is thread safe?
andimarek
Nov 23, 2018
Member
I like the idea of adding a ThreadSafe annotation.
I like the idea of adding a ThreadSafe annotation.
| return this; | ||
| } | ||
|
|
||
| public Builder context(UnaryOperator<GraphQLContext.Builder> contextBuilderFunction) { |
tsroka
Nov 13, 2018
Member
just wondering if it would be easier to understand the api if the method name would be something like .defaultContext in this case, as for me it would be hard to understand which one should be used: context with object or context with builder (without looking at the docs)
just wondering if it would be easier to understand the api if the method name would be something like .defaultContext in this case, as for me it would be hard to understand which one should be used: context with object or context with builder (without looking at the docs)
| */ | ||
| @PublicApi | ||
| @SuppressWarnings("unchecked") | ||
| public class GraphQLContext { |
andimarek
Nov 23, 2018
Member
I like the idea of adding a ThreadSafe annotation.
I like the idea of adding a ThreadSafe annotation.
|
this is a small breaking change, because the context was |
|
added new annotation as suggested |
This will help encourage people to get started on a simple map like context object
Inspired by https://projectreactor.io/docs/core/milestone/api/reactor/util/context/Context.html
Out of the box there is a "context" object available. It can be replaced but you can rely on it IF you do nothing.
I have made it mutable (but threadsafe) so people can use it to pass information between fetchers. Because lots of people end up doing that