Skip to content
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

Prepare for v23 #188

Merged
merged 1 commit into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions documentation/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repositories {
}

dependencies {
implementation 'com.graphql-java:graphql-java:22.3'
implementation 'com.graphql-java:graphql-java:23.0'
}
```
</TabItem>
Expand All @@ -38,7 +38,7 @@ repositories {
}

dependencies {
implementation("com.graphql-java:graphql-java:22.3")
implementation("com.graphql-java:graphql-java:23.0")
}
```
</TabItem>
Expand All @@ -51,7 +51,7 @@ Dependency:
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
<version>22.3</version>
<version>23.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const config = {
routeBasePath: 'documentation',
sidebarPath: require.resolve('./sidebars.js'),
editUrl: 'https://github.com/graphql-java/graphql-java-page/edit/master/',
lastVersion: "v22",
lastVersion: "v23",
versions: {
current: {
label: "master",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ It might look like the following :

```java
DataFetcher productsDataFetcher = new DataFetcher<List<ProductDTO>>() {
@Override
public List<ProductDTO> get(DataFetchingEnvironment environment) {
DatabaseSecurityCtx ctx = environment.getGraphQlContext().get("databaseSecurityCtx");

List<ProductDTO> products;
String match = environment.getArgument("match");
if (match != null) {
products = fetchProductsFromDatabaseWithMatching(ctx, match);
} else {
products = fetchAllProductsFromDatabase(ctx);
@Override
public List<ProductDTO> get(DataFetchingEnvironment environment) {
DatabaseSecurityCtx ctx = environment.getGraphQlContext().get("databaseSecurityCtx");

List<ProductDTO> products;
String match = environment.getArgument("match");
if (match != null) {
products = fetchProductsFromDatabaseWithMatching(ctx, match);
} else {
products = fetchAllProductsFromDatabase(ctx);
}
return products;
}
return products;
}
};
```

Expand All @@ -80,25 +80,25 @@ argument. We can have the ProductDTO have logic that applies this date formatti
```java
class ProductDTO {

private ID id;
private String name;
private String description;
private Double cost;
private Double tax;
private LocalDateTime launchDate;
private ID id;
private String name;
private String description;
private Double cost;
private Double tax;
private LocalDateTime launchDate;

// ...
// ...

public String getName() {
return name;
}
public String getName() {
return name;
}

// ...
// ...

public String getLaunchDate(DataFetchingEnvironment environment) {
String dateFormat = environment.getArgument("dateFormat");
return yodaTimeFormatter(launchDate,dateFormat);
}
public String getLaunchDate(DataFetchingEnvironment environment) {
String dateFormat = environment.getArgument("dateFormat");
return yodaTimeFormatter(launchDate,dateFormat);
}
}
```

Expand Down Expand Up @@ -135,32 +135,32 @@ Every data fetcher is passed a ``graphql.schema.DataFetchingEnvironment`` object
and what arguments have been provided. Here are some of the more interesting parts of ``DataFetchingEnvironment``.

* ``<T> T getSource()`` - the ``source`` object is used to get information for a field. Its the object that is the result
of the parent field fetch. In the common case it is an in memory DTO object and hence simple POJO getters will be used for fields values. In more complex cases, you may examine it to know
how to get the specific information for the current field. As the graphql field tree is executed, each returned field value
becomes the ``source`` object for child fields.
of the parent field fetch. In the common case it is an in memory DTO object and hence simple POJO getters will be used for fields values. In more complex cases, you may examine it to know
how to get the specific information for the current field. As the graphql field tree is executed, each returned field value
becomes the ``source`` object for child fields.

* ``<T> T getRoot()`` - this special object is used to seed the graphql query. The ``root`` and the ``source`` is the same thing for the
top level fields. The root object never changes during the query and it may be null and hence no used.
top level fields. The root object never changes during the query and it may be null and hence no used.

* ``Map<String, Object> getArguments()`` - this represents the arguments that have been provided on a field and the values of those
arguments that have been resolved from passed in variables, AST literals and default argument values. You use the arguments
of a field to control what values it returns.
arguments that have been resolved from passed in variables, AST literals and default argument values. You use the arguments
of a field to control what values it returns.

* ``<T> T getGraphQLContext()`` - the context object is set up when the query is first executed and stays the same over the lifetime
of the query. The context is a map that can contain any value and is typically used to give each data fetcher some calling context needed
when trying to get field data. For example the current user credentials or the database connection parameters could be contained
with a context object so that data fetchers can make business layer calls. One of the key design decisions you have as a graphql
system designer is how you will use context in your fetchers if at all. Some people use a dependency framework that injects context into
data fetchers automatically and hence don't need to use this.
of the query. The context is a map that can contain any value and is typically used to give each data fetcher some calling context needed
when trying to get field data. For example the current user credentials or the database connection parameters could be contained
with a context object so that data fetchers can make business layer calls. One of the key design decisions you have as a graphql
system designer is how you will use context in your fetchers if at all. Some people use a dependency framework that injects context into
data fetchers automatically and hence don't need to use this.

* ``ExecutionStepInfo getExecutionStepInfo()`` - the field type information is a catch all bucket of field type information that is built up as
the query is executed. The following section explains more on this.
the query is executed. The following section explains more on this.

* ``DataFetchingFieldSelectionSet getSelectionSet()`` - the selection set represents the child fields that have been "selected" under neath the
currently executing field. This can be useful to help look ahead to see what sub field information a client wants. The following section explains more on this.
currently executing field. This can be useful to help look ahead to see what sub field information a client wants. The following section explains more on this.

* ``ExecutionId getExecutionId()`` - each query execution is given a unique id. You can use this perhaps on logs to tag each individual
query.
query.

## The interesting parts of ExecutionStepInfo

Expand All @@ -182,7 +182,7 @@ query {
name
description
sellingLocations {
state
state
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description: How SDL Directives can be used to adjust the behavior of your graph

There are two broad categories of directives, schema and operation directives. Schema directives are used on schema elements, and operation directives are used in operations within a GraphQL document.

Often, operation directives are also called "query directives", although they can be used in any GraphQL operation. Whilst both names can be used interchangeably, note that GraphQL Java class names use "query directives".
Often, operation directives are also called "query directives", although they can be used in any GraphQL operation. Whilst both names can be used interchangeably, note that GraphQL Java class names use "query directives".

Note for those who love the details: the terminology of directives is a bit confusing. It is technically possible to define a directive that is both a schema and operation directive, in other words, defined for both schema and operation locations. However in practice, this is not common.

Expand Down Expand Up @@ -310,7 +310,7 @@ When the above was executed each directive would be applied one on top of the ot
to preserve the previous data fetcher to retain behaviour (unless of course you mean to throw it away)

# Operation Directives (also known as Query Directives)
Let's define an operation directive `@cache`, which can be used on operation fields.
Let's define an operation directive `@cache`, which can be used on operation fields.

```graphql
# Can only be used on a field in a GraphQL document
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repositories {
}

dependencies {
implementation 'com.graphql-java:graphql-java:22.3'
implementation 'com.graphql-java:graphql-java:23.0'
}
```
</TabItem>
Expand All @@ -38,7 +38,7 @@ repositories {
}

dependencies {
implementation("com.graphql-java:graphql-java:22.3")
implementation("com.graphql-java:graphql-java:23.0")
}
```
</TabItem>
Expand All @@ -51,7 +51,7 @@ Dependency:
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
<version>22.3</version>
<version>23.0</version>
</dependency>
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ You can use the `LegacyCoercingInputInterceptor` implementation to monitor traff

```java
InputInterceptor legacyInputInterceptor = LegacyCoercingInputInterceptor.observesValues((inputValue, graphQLInputType) -> {
emitAMetric(inputValue, graphQLInputType);
emitAMetric(inputValue, graphQLInputType);
});

ExecutionInput executionInput = ExecutionInput.newExecutionInput()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version-v22/tutorialSidebar": [
"version-v23/tutorialSidebar": [
{
"type": "autogenerated",
"dirName": "."
Expand Down
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[
"v22"
"v23"
]