Skip to content

Commit 89a071b

Browse files
authored
Merge pull request #130 from graphql-java/v21-release
v21 release
2 parents 2df0449 + a78f228 commit 89a071b

24 files changed

Lines changed: 190 additions & 42 deletions

blog/2023-07-11-v21-released.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: "Version 21 released"
3+
authors: donna
4+
slug: v21-released
5+
---
6+
7+
We are pleased to announce the release of graphql-java v21.0! Thanks to everyone in the community who contributed to the release, whether that was code, helping to report issues, or participating in discussions.
8+
9+
And a very Happy 8th Birthday to graphql-java, who celebrated their birthday last week!
10+
11+
This is a **breaking change** release, including upgrading to Java 11 and changes to `parseValue` coercion. See the full release notes on [GitHub](https://github.com/graphql-java/graphql-java/releases/tag/v21.0).

documentation/getting-started.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repositories {
2525
}
2626
2727
dependencies {
28-
implementation 'com.graphql-java:graphql-java:20.4'
28+
implementation 'com.graphql-java:graphql-java:21.0'
2929
}
3030
```
3131
</TabItem>
@@ -38,7 +38,7 @@ repositories {
3838
}
3939

4040
dependencies {
41-
implementation("com.graphql-java:graphql-java:20.4")
41+
implementation("com.graphql-java:graphql-java:21.0")
4242
}
4343
```
4444
</TabItem>
@@ -51,7 +51,7 @@ Dependency:
5151
<dependency>
5252
<groupId>com.graphql-java</groupId>
5353
<artifactId>graphql-java</artifactId>
54-
<version>20.4</version>
54+
<version>21.0</version>
5555
</dependency>
5656
```
5757

documentation/instrumentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ GraphQL.newGraphQL(schema)
9898
``graphql.execution.instrumentation.tracing.TracingInstrumentation`` is an ``Instrumentation`` implementation that creates tracing information
9999
about the query that is being executed.
100100

101-
It follows the Apollo proposed tracing format defined at `https://github.com/apollographql/apollo-tracing <https://github.com/apollographql/apollo-tracing>`_
101+
It follows the Apollo proposed tracing format defined at [https://github.com/apollographql/apollo-tracing](https://github.com/apollographql/apollo-tracing).
102102

103103
A detailed tracing map will be created and placed in the ``extensions`` section of the result.
104104

readme.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Then update `lastVersion` inside `docusaurus.config.js`
4747
lastVersion: "v20",
4848
```
4949

50-
Finally, change the Maven and Gradle sections in [documentation/getting-started.mdx](/documentation/getting-started.mdx) and versioned documentation inside `versioned_docs`.
50+
Delete the oldest version by deleting the oldest version's directory inside `versioned_docs` and the corresponding file in `versioned_sidebars`. Then delete the oldest version from `versions.json`.
51+
52+
Finally, change the Maven and Gradle sections in [documentation/getting-started.mdx](/documentation/getting-started.mdx).
5153

5254
For more, see the [Docusaurus versioning documentation](https://docusaurus.io/docs/versioning).

versioned_docs/version-v20/getting-started.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import TabItem from '@theme/TabItem';
1010

1111
# Getting started
1212

13-
`graphql-java` requires at least Java 8.
13+
`graphql-java` v20.x requires at least Java 8.
1414

1515
## How to use the latest release with Gradle
1616

File renamed without changes.

versioned_docs/version-v19/data-fetching.md renamed to versioned_docs/version-v21/data-fetching.md

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type Product {
2828
description : String
2929
cost : Float
3030
tax : Float
31-
launchDate(dateFormat : String = "dd, MMM, yyyy") : String
31+
launchDate(dateFormat : String = "dd, MMM, yyyy') : String
3232
}
3333
```
3434
@@ -113,24 +113,9 @@ called ``fieldX`` or a map key called ``fieldX`` if the backing object is a ``Ma
113113
However you may have small differences between your graphql schema naming and runtime object naming. For example imagine that ``Product.description`` is actually
114114
represented as ``getDesc()`` in the runtime backing Java object.
115115
116-
If you are using SDL to specify your schema then you can use the ``@fetch`` directive to indicate this remapping.
117-
118-
```graphql
119-
directive @fetch(from : String!) on FIELD_DEFINITION
120-
121-
type Product {
122-
id : ID
123-
name : String
124-
description : String @fetch(from:"desc")
125-
cost : Float
126-
tax : Float
127-
}
128-
```
129-
116+
You can specify it directly by wiring in a field data fetcher.
130117
This will tell the ``graphql.schema.PropertyDataFetcher`` to use the property name ``desc`` when fetching data for the graphql field named ``description``.
131118
132-
If you are hand coding your schema then you can just specify it directly by wiring in a field data fetcher.
133-
134119
```java
135120
GraphQLFieldDefinition descriptionField = GraphQLFieldDefinition.newFieldDefinition()
136121
.name("description")

versioned_docs/version-v19/data-mapping.md renamed to versioned_docs/version-v21/data-mapping.md

Lines changed: 153 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ title: "Data mapping"
33
date: 2018-09-09T12:52:46+10:00
44
description: How graphql-java maps object data to graphql types
55
---
6-
# Mapping data
6+
# Mapping output data
77

8-
## How graphql maps object data to types
8+
## How graphql maps object data to output types
99

1010
At its heart graphql is all about declaring a type schema and mapping that over backing runtime data.
1111

@@ -166,3 +166,154 @@ For every object in the list it will look for an ``id`` field, find it by name i
166166
response. It does that for every field in the query on that type.
167167

168168
By creating a "unified view" at the higher level data fetcher, you have mapped between your runtime view of the data and the graphql schema view of the data.
169+
170+
# Mapping input data
171+
172+
## How graphql maps object data to input types
173+
174+
Input type values are provided to as input to a graphql operation. The three kinds of types that can be input are **Enums**, **Scalars** and **Input Object Types** and the **List** and **Non-Null** variants of these
175+
type kinds.
176+
177+
The following outlines how graphql-java represents these type kinds in JVM runtime terms.
178+
179+
### Enums
180+
181+
graphql-java maps input `Enum` values by name. When you create the `graphql.schema.GraphQLEnumType` instance you can in theory map a name `java.lang.String`
182+
to any JVM object. But this is not common at all. Mostly the name of the enum value is the actual value of it.
183+
184+
```graphql
185+
enum RGB {
186+
RED, BLUE, GREEN
187+
}
188+
189+
scalar Pantone
190+
191+
type Query {
192+
toPantone( color : RGB) : Pantone
193+
}
194+
```
195+
196+
The `RGB` enum type above has the runtime JVM `java.lang.String` values of `"RED"`,`"BLUE"` and `"GREEN"` on input and output.
197+
198+
The graphql-java system allow you to also input `java.lang.Enum` but this is not common at all for input. The reason it's not common is that this would
199+
require you to turn your network input into Java enums and this is not a common action of serialisation frameworks.
200+
201+
If the input value to the enum comes from the graphql operation document, then the input value will initially be a `graphql.language.EnumValue` which
202+
is the AST representation of a graphql `Enum` value. This will be converted by graphql-java to a value by name.
203+
204+
So a query document like the following will end up mapping the AST enum input value `RED` to the JVM value `"RED"`.
205+
206+
```graphql
207+
query MyColors {
208+
toPantone(color : RED)
209+
}
210+
```
211+
212+
### Scalars
213+
214+
The input values to a scalar are controlled by the scalar implementation. If their `graphql.schema.Coercing#parseValue(java.lang.Object, graphql.GraphQLContext, java.util.Locale)` accepts
215+
a certain value then it's up to them to decide what JVM object is returned by the scalar code.
216+
217+
The graphql-java scalars will return the following values as JVM object input values.
218+
219+
* **String** aka ``GraphQLString`` - will produce a `java.lang.String`
220+
* **Boolean** aka ``GraphQLBoolean`` - will produce a `java.lang.Boolean`
221+
* **Int** aka ``GraphQLInt`` - will produce a `java.lang.Integer`
222+
* **Float** aka ``GraphQLFloat`` - will produce a `java.lang.Double`
223+
* **ID** aka ``GraphQLID`` - will produce a `java.lang.String`
224+
225+
### Input Object Types
226+
227+
Input object types are complex input types with named input fields. The runtime JVM representation will be a `java.util.Map`. Specifically
228+
a map that ordered its keys in a predictable way.
229+
230+
So imagine this input type named `Person`
231+
232+
```graphql
233+
input Person {
234+
name : String!
235+
age : Int!
236+
}
237+
238+
type Query {
239+
contact(person : Person) : String
240+
}
241+
```
242+
243+
This will be represented at runtime as a `java.util.Map` containing a key `name` with a `java.lang.String` value and
244+
a key `age` with a `java.lang.Integer` value.
245+
246+
### Nonnull input types
247+
248+
There is no special runtime object used for non-null input types other than the called code can safely assume that the object
249+
is not a null value.
250+
251+
```graphql
252+
type Query {
253+
field(arg1 : String!, arg2 : String) : String
254+
}
255+
```
256+
257+
So in the example above the `arg1` field argument will always be a non-null `java.lang.String` value while `arg2` may be `null` at runtime.
258+
259+
### Lists of input types
260+
261+
If the input type is a graphql list input type then the runtime JVM representation will be a `java.util.List` of the wrapped input type.
262+
263+
So as an example, given
264+
265+
```graphql
266+
type Query {
267+
field(arg : [String!]!) : String
268+
}
269+
```
270+
271+
The `arg` field argument would be a non-null `java.util.List` containing zero or more non-null `java.lang.String` values.
272+
273+
In graphql you can say that a list is non-null and its entries are also non-null
274+
however there is no way to say that the list has one or more entries.
275+
276+
The `arg` field argument above could be an empty list. It will not be `null` but it could be empty.
277+
278+
Complex runtime input values can be declared and the runtime representation will reflect that.
279+
280+
```graphql
281+
input Person {
282+
name : String!
283+
age : Int!
284+
friends : [Person!]
285+
}
286+
287+
type Query {
288+
contacts(people : [Person!]!) : String
289+
}
290+
291+
```
292+
293+
The `person` field argument would be a `java.util.List` containing one or more `java.util.Map`s, where each map contained named entries
294+
and the `friends` map entry could itself be a `java.util.List` containing one or more `java.util.Map`s, so imagine
295+
the following representation at runtime :
296+
297+
```java
298+
List.of(
299+
Map.of("name", "Brad",
300+
"age", 42,
301+
"friends", List.of(
302+
Map.of("name", "Bill",
303+
"age", 17,
304+
"friends", List.of()
305+
)
306+
)
307+
),
308+
Map.of("name", "Andreas",
309+
"age", 34,
310+
"friends", List.of(
311+
Map.of("name", "Ted",
312+
"age", 15,
313+
"friends", List.of()
314+
)
315+
)
316+
)
317+
);
318+
319+
```

0 commit comments

Comments
 (0)