You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/tools/_index.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,6 @@ GraphQL Java Tools aims for seamless integration with Java, but works for any JV
23
23
A few libraries exist to ease the boilerplate pain, including [GraphQL-Java's built-in schema-first wiring](http://graphql-java.readthedocs.io/en/latest/schema.html), but none (so far) do type and datafetcher discovery.
24
24
***Stateful Data Fetchers**: If you're using an IOC container (like Spring), it's hard to wire up datafetchers that make use of beans you've already defined without a bunch of fragile configuration. GraphQL Java Tools allows you to register "Resolvers" for any type that can bring state along and use that to resolve fields.
25
25
***Generated DataFetchers**: GraphQL Java Tools automatically creates data fetchers for your fields that call the appropriate method on your java class. This means all you have to do to create a new field is add the field definition to your schema and add a corresponding method on your class.
26
-
***Type->Class Discovery**: GraphQL Java Tools starts from your root objects (Query, Mutation) and, as it's generating data fetchers for you, starts to learn about the classes you use for a certain GraphQL type.
27
-
***Class Validation**: Since there aren't any compile-time checks of the type->class relationship, GraphQL Java Tools will warn you if you provide classes/types that you don't need to, as well as erroring if you use the wrong Java class for a certain GraphQL type when it builds the schema.
26
+
***Type → Class Discovery**: GraphQL Java Tools starts from your root objects (Query, Mutation) and, as it's generating data fetchers for you, starts to learn about the classes you use for a certain GraphQL type.
27
+
***Class Validation**: Since there aren't any compile-time checks of the type → class relationship, GraphQL Java Tools will warn you if you provide classes/types that you don't need to, as well as throwing errors if you use the wrong Java class for a certain GraphQL type when it builds the schema.
28
28
***Unit Testing**: Since your GraphQL schema is independent of your data model, this makes your classes simple and extremely testable.
Copy file name to clipboardExpand all lines: content/tools/schema-definition/index.md
+9-11Lines changed: 9 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ type Author {
55
55
```
56
56
57
57
GraphQLJavaToolswillexpecttobegiventhreeclassesthatmaptotheGraphQLtypes: `Query`, `Book`, and `Author`.
58
-
TheDataclassesforBookandAuthoraresimple:
58
+
TheDataclassesfor`Book`and`Author`aresimple:
59
59
60
60
```java
61
61
classBook {
@@ -81,10 +81,10 @@ class Author {
81
81
}
82
82
```
83
83
84
-
But what about the complex fields on `Query` and `Book`?
84
+
What about the complex fields on `Query` and `Book`?
85
85
These are handled by "Resolvers". Resolvers are object instances that reference the "Data Class" they resolve fields for.
86
86
87
-
The BookResolver might look something like this:
87
+
The `BookResolver` might look something like this:
88
88
```java
89
89
classBookResolverimplementsGraphQLResolver<Book>/* This class is a resolver for the Book "Data Class" */ {
90
90
@@ -100,13 +100,13 @@ class BookResolver implements GraphQLResolver<Book> /* This class is a resolver
100
100
}
101
101
```
102
102
103
-
When given a BookResolver instance, GraphQL Java Tools first attempts to map fields to methods on the resolver before mapping them to fields or methods on the data class.
103
+
When given a `BookResolver` instance, GraphQL Java Tools first attempts to map fields to methods on the resolver before mapping them to fields or methods on the data class.
104
104
If there is a matching method on the resolver, the data class instance is passed as the first argument to the resolver function. This does not apply to root resolvers, since those don't have a data class to resolve for.
105
-
An optional argument can be defined to inject the `DataFetchingEnvironment`, and must be the last argument.
105
+
An optional parameter can be defined to inject the `DataFetchingEnvironment`, and must be the last argument.
106
106
107
107
### Root Resolvers
108
108
109
-
Since the Query/Mutation/Subscription objects are root GraphQL objects, they doesn't have an associated data class. In those cases, any resolvers implementing `GraphQLQueryResolver`, `GraphQLMutationResolver`, or `GraphQLSubscriptionResolver` will be searched for methods that map to fields in their respective root types. Root resolver methods can be spread between multiple resolvers, but a simple example is below:
109
+
Since the Query/Mutation/Subscription objects are root GraphQL objects, they don't have an associated data class. In those cases, any resolvers implementing `GraphQLQueryResolver`, `GraphQLMutationResolver`, or `GraphQLSubscriptionResolver` will be searched for methods that map to fields in their respective root types. Root resolver methods can be spread between multiple resolvers, but a simple example is below:
110
110
```java
111
111
classQueryimplementsGraphQLQueryResolver {
112
112
@@ -152,9 +152,7 @@ Last of all, if the data class implements`java.util.Map` then:
152
152
1.`method get(name)`
153
153
154
154
155
-
*Note:* All reflection discovery is done on startup, and runtime reflection method calls use [reflectasm](https://github.com/EsotericSoftware/reflectasm), which increases performance and unifies stacktraces. No more `InvocationTargetException`!
156
-
157
-
*Note:*`java.util.Optional` can be used for nullable field arguments and nullable return values, and the schema parser will verify that it's not used with non-null field arguments and return values.
155
+
<!--*Note:* `java.util.Optional` can be used for nullable field arguments and nullable return values, and the schema parser will verify that it's not used with non-null field arguments and return values.-->
158
156
159
157
*Note:* Methods on `java.lang.Object` are excluded from method matching, for example a field named `class` will require a method named `getFieldClass` defined.
160
158
@@ -217,7 +215,7 @@ SchemaParser.newParser()
217
215
218
216
## Making the graphql-java Schema Instance
219
217
220
-
After you've passed all relavant schema files/class to the parser, call `.build()` and `.makeExecutableSchema()` to get a graphql-java `GraphQLSchema`:
218
+
After you've passed all relevant schema files/class to the parser, call `.build()` and `.makeExecutableSchema()` to get a graphql-java `GraphQLSchema`:
221
219
222
220
```java
223
221
SchemaParser.newParser()
@@ -226,7 +224,7 @@ SchemaParser.newParser()
226
224
.makeExecutableSchema()
227
225
```
228
226
229
-
If you want to build the `GraphQLSchema` yourself, you can get all of the parsed objects with `parseSchemaObjects()`:
227
+
If you want to build the `GraphQLSchema` yourself, you can get all the parsed objects with `parseSchemaObjects()`:
0 commit comments