Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Enigmatis/graphql-java-annotations
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v7.0
Choose a base ref
...
head repository: Enigmatis/graphql-java-annotations
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Jun 20, 2019

  1. Copy the full SHA
    b684cee View commit details

Commits on Jun 25, 2019

  1. Merge pull request #214 from nhpatt/remove_static

    Remove static method to use the current instance
    yarinvak authored Jun 25, 2019
    Copy the full SHA
    d714dc0 View commit details

Commits on Jul 7, 2019

  1. Copy the full SHA
    3e53e65 View commit details

Commits on Jul 9, 2019

  1. Copy the full SHA
    f9a83d0 View commit details
  2. Copy the full SHA
    e860593 View commit details
  3. Merge pull request #215 from osher-sade/master

    fixed a bug that could cause directives to be built with synthetic fields
    yarinvak authored Jul 9, 2019
    Copy the full SHA
    e0c48a4 View commit details
  4. Update gradle.properties

    yarinvak authored Jul 9, 2019
    Copy the full SHA
    644a119 View commit details
  5. Update README.md

    yarinvak authored Jul 9, 2019
    Copy the full SHA
    261f912 View commit details
  6. Copy the full SHA
    18cf896 View commit details
  7. Merge pull request #216 from Enigmatis/development

    release 7.0.1
    yarinvak authored Jul 9, 2019
    Copy the full SHA
    978ed47 View commit details

Commits on Jul 15, 2019

  1. Set correct version for annotations in README.MD

    Sander Koenders authored Jul 15, 2019
    Copy the full SHA
    13dcc0b View commit details

Commits on Jul 24, 2019

  1. Merge pull request #217 from Archcry/patch-1

    Set correct version for annotations in README.MD
    yarinvak authored Jul 24, 2019
    Copy the full SHA
    a18d78d View commit details

Commits on Aug 14, 2019

  1. Copy the full SHA
    06fc05b View commit details
  2. if empty string is sent as a description in @GraphQLDeprecate - set i…

    …t to "Deprecated" so graphiql will be able to parse it and present it as a deprecated field
    yarinvak committed Aug 14, 2019
    Copy the full SHA
    bbb8b73 View commit details
  3. if empty string is sent as a description in @GraphQLDeprecate - set i…

    …t to "Deprecated" so graphiql will be able to parse it and present it as a deprecated field
    yarinvak committed Aug 14, 2019
    Copy the full SHA
    014cfad View commit details
  4. Copy the full SHA
    f32c539 View commit details
  5. Merge pull request #220 from yarinvak/graphqldeprecated-refactoring

    Fixing GraphQLDeprecate not showing in graphiql
    yarinvak authored Aug 14, 2019
    Copy the full SHA
    1230872 View commit details
  6. Copy the full SHA
    cde4afc View commit details
  7. Merge pull request #221 from yarinvak/graphql-java-13

    Graphql java 13
    yarinvak authored Aug 14, 2019
    Copy the full SHA
    eebbaeb View commit details
  8. Update README.md

    yarinvak authored Aug 14, 2019
    Copy the full SHA
    558c23e View commit details

Commits on Aug 15, 2019

  1. Update gradle.properties

    yarinvak authored Aug 15, 2019
    Copy the full SHA
    ac5e1e2 View commit details
  2. Copy the full SHA
    8b7716f View commit details
  3. Merge pull request #223 from Enigmatis/master

    Merge pull request #222 from Enigmatis/development
    yarinvak authored Aug 15, 2019
    Copy the full SHA
    9a5e919 View commit details

Commits on Sep 20, 2019

  1. directives update

    yarinvak committed Sep 20, 2019
    Copy the full SHA
    284c84b View commit details
  2. Copy the full SHA
    01ba566 View commit details
  3. directive and wiring

    yarinvak committed Sep 20, 2019
    Copy the full SHA
    f3d091d View commit details
  4. added tests

    yarinvak committed Sep 20, 2019
    Copy the full SHA
    b69422c View commit details
  5. tested classes

    yarinvak committed Sep 20, 2019
    Copy the full SHA
    14f6bd3 View commit details
  6. refactor directives to add support for java annotation as a graphql d…

    …irective and a method declaration as directive inside query class or somewhere else
    yarinvak committed Sep 20, 2019
    Copy the full SHA
    4e1d3b8 View commit details
  7. Copy the full SHA
    05b5ee5 View commit details

Commits on Sep 21, 2019

  1. Copy the full SHA
    c9030fb View commit details
  2. fix tests

    yarinvak committed Sep 21, 2019
    Copy the full SHA
    94e0ba8 View commit details
  3. changed readme

    yarinvak committed Sep 21, 2019
    Copy the full SHA
    edeb801 View commit details
  4. Copy the full SHA
    d5eaddb View commit details
  5. add tests

    yarinvak committed Sep 21, 2019
    Copy the full SHA
    129d239 View commit details
  6. FIX TEST

    yarinvak committed Sep 21, 2019
    Copy the full SHA
    80fcb7d View commit details
  7. update license

    yarinvak committed Sep 21, 2019
    Copy the full SHA
    0a19ecf View commit details
  8. add tests

    yarinvak committed Sep 21, 2019
    Copy the full SHA
    5653b0b View commit details
  9. add tests

    yarinvak committed Sep 21, 2019
    Copy the full SHA
    440269f View commit details
  10. add support to list todo

    yarinvak committed Sep 21, 2019
    Copy the full SHA
    e4df24e View commit details

Commits on Sep 24, 2019

  1. support list

    yarinvak committed Sep 24, 2019
    Copy the full SHA
    3f0f3f4 View commit details

Commits on Oct 13, 2019

  1. code review fixes

    yarinvak committed Oct 13, 2019
    Copy the full SHA
    4543c76 View commit details
  2. remove unnecessary todos

    yarinvak committed Oct 13, 2019
    Copy the full SHA
    2feee80 View commit details
  3. Merge pull request #224 from yarinvak/new-way-directives

    New way of using directives
    yarinvak authored Oct 13, 2019
    Copy the full SHA
    3ffd5eb View commit details
  4. v7.2

    yarinvak committed Oct 13, 2019
    Copy the full SHA
    91ebff7 View commit details
  5. Copy the full SHA
    1587e13 View commit details
  6. Merge pull request #226 from Enigmatis/master

    Master
    yarinvak authored Oct 13, 2019
    Copy the full SHA
    7aad713 View commit details

Commits on Oct 14, 2019

  1. Copy the full SHA
    d528457 View commit details
  2. license

    yarinvak committed Oct 14, 2019
    Copy the full SHA
    14c1ac1 View commit details
  3. Merge pull request #227 from yarinvak/support-new-directive-in-schema…

    …-creator
    
    Support new directives way in the schema creator
    yarinvak authored Oct 14, 2019
    Copy the full SHA
    d193b7d View commit details
Showing with 2,800 additions and 1,460 deletions.
  1. +34 −0 .github/workflows/build.yml
  2. +30 −0 .github/workflows/publish.yml
  3. +0 −3 .travis.yml
  4. +0 −2 LICENSE
  5. +135 −22 README.md
  6. +18 −0 RELEASE.md
  7. +0 −20 azure-pipelines.yml
  8. +2 −0 bnd.bnd
  9. +43 −59 build.gradle
  10. +0 −3 bundle.bnd
  11. +1 −1 gradle.properties
  12. BIN gradle/wrapper/gradle-wrapper.jar
  13. +1 −2 gradle/wrapper/gradle-wrapper.properties
  14. +41 −27 gradlew
  15. +21 −1 gradlew.bat
  16. BIN graphql-annotations.png
  17. BIN polaris-iconsmalredl.png
  18. +49 −6 src/main/java/graphql/annotations/AnnotationsSchemaCreator.java
  19. +28 −0 src/main/java/graphql/annotations/annotationTypes/GraphQLConstructor.java
  20. +1 −1 src/main/java/graphql/annotations/annotationTypes/GraphQLDeprecate.java
  21. +3 −2 src/main/java/graphql/annotations/annotationTypes/{GraphQLBatched.java → GraphQLIgnore.java}
  22. +5 −3 ...main/java/graphql/annotations/{directives → annotationTypes/directives/activation}/Directive.java
  23. +5 −3 src/main/java/graphql/annotations/annotationTypes/{ → directives/activation}/GraphQLDirectives.java
  24. +2 −2 ...annotations/{directives/creation → annotationTypes/directives/definition}/DirectiveLocations.java
  25. +32 −0 ...in/java/graphql/annotations/annotationTypes/directives/definition/GraphQLDirectiveDefinition.java
  26. +0 −40 src/main/java/graphql/annotations/dataFetchers/BatchedMethodDataFetcher.java
  27. +32 −19 src/main/java/graphql/annotations/dataFetchers/MethodDataFetcher.java
  28. +2 −1 src/main/java/graphql/annotations/directives/AnnotationsWiringEnvironment.java
  29. +7 −6 src/main/java/graphql/annotations/directives/AnnotationsWiringEnvironmentImpl.java
  30. +196 −0 src/main/java/graphql/annotations/directives/DirectiveSchemaVisitor.java
  31. +0 −101 src/main/java/graphql/annotations/directives/DirectiveWirer.java
  32. +23 −10 src/main/java/graphql/annotations/directives/DirectiveWiringMapRetriever.java
  33. +23 −0 src/main/java/graphql/annotations/directives/TreeTransformerUtilWrapper.java
  34. +36 −0 src/main/java/graphql/annotations/processor/DirectiveAndWiring.java
  35. +28 −16 src/main/java/graphql/annotations/processor/GraphQLAnnotations.java
  36. +4 −4 src/main/java/graphql/annotations/processor/ProcessingElementsContainer.java
  37. +6 −0 src/main/java/graphql/annotations/processor/directives/CommonPropertiesCreator.java
  38. +29 −3 src/main/java/graphql/annotations/processor/directives/DirectiveArgumentCreator.java
  39. +47 −9 src/main/java/graphql/annotations/processor/directives/DirectiveCreator.java
  40. +3 −2 src/main/java/graphql/annotations/processor/retrievers/GraphQLExtensionsHandler.java
  41. +13 −24 src/main/java/graphql/annotations/processor/retrievers/GraphQLFieldRetriever.java
  42. +1 −1 src/main/java/graphql/annotations/processor/retrievers/GraphQLObjectInfoRetriever.java
  43. +2 −12 src/main/java/graphql/annotations/processor/retrievers/GraphQLTypeRetriever.java
  44. +3 −7 src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/ArgumentBuilder.java
  45. +1 −1 src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/DeprecateBuilder.java
  46. +105 −28 src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/DirectivesBuilder.java
  47. +1 −5 .../java/graphql/annotations/processor/retrievers/fieldBuilders/method/MethodDataFetcherBuilder.java
  48. +1 −10 src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/method/MethodTypeBuilder.java
  49. +2 −1 src/main/java/graphql/annotations/processor/typeBuilders/OutputObjectBuilder.java
  50. +0 −60 src/main/java/graphql/annotations/processor/typeFunctions/BatchedTypeFunction.java
  51. +3 −4 src/main/java/graphql/annotations/processor/typeFunctions/BigDecimalFunction.java
  52. +3 −4 src/main/java/graphql/annotations/processor/typeFunctions/BigIntegerFunction.java
  53. +3 −4 src/main/java/graphql/annotations/processor/typeFunctions/ByteFunction.java
  54. +3 −4 src/main/java/graphql/annotations/processor/typeFunctions/CharFunction.java
  55. +1 −3 src/main/java/graphql/annotations/processor/typeFunctions/IDFunction.java
  56. +3 −4 src/main/java/graphql/annotations/processor/typeFunctions/LongFunction.java
  57. +3 −4 src/main/java/graphql/annotations/processor/typeFunctions/ShortFunction.java
  58. +95 −0 src/main/java/graphql/annotations/processor/util/ClassUtils.java
  59. +6 −9 src/main/java/graphql/annotations/processor/util/CodeRegistryUtil.java
  60. +15 −4 src/main/java/graphql/annotations/processor/util/ConnectionUtil.java
  61. +44 −0 src/main/java/graphql/annotations/processor/util/DirectiveJavaAnnotationUtil.java
  62. +35 −0 src/main/java/graphql/annotations/processor/util/GraphQLTypeNameResolver.java
  63. +4 −2 src/main/java/graphql/annotations/processor/util/ObjectUtil.java
  64. +1 −3 src/main/java/graphql/annotations/strategies/EnhancedExecutionStrategy.java
  65. +76 −3 src/test/java/graphql/annotations/AnnotationsSchemaCreatorTest.java
  66. +0 −120 src/test/java/graphql/annotations/GraphQLBatchedTest.java
  67. +6 −2 src/test/java/graphql/annotations/GraphQLDataFetcherTest.java
  68. +121 −5 src/test/java/graphql/annotations/GraphQLDirectiveCreationTest.java
  69. +293 −0 src/test/java/graphql/annotations/GraphQLDirectivesViaAnnotationDefinitionTest.java
  70. +48 −65 ...a/graphql/annotations/{GraphQLDirectivesTest.java → GraphQLDirectivesViaClassDefinitionTest.java}
  71. +73 −0 src/test/java/graphql/annotations/GraphQLDirectivesViaMethodDefinitionTest.java
  72. +61 −2 src/test/java/graphql/annotations/GraphQLExtensionsTest.java
  73. +6 −2 src/test/java/graphql/annotations/GraphQLFragmentTest.java
  74. +37 −0 src/test/java/graphql/annotations/GraphQLHelper.java
  75. +119 −0 src/test/java/graphql/annotations/GraphQLIgnoredFieldParameterTest.java
  76. +17 −22 src/test/java/graphql/annotations/GraphQLInputTest.java
  77. +3 −5 src/test/java/graphql/annotations/GraphQLInterfaceTest.java
  78. +28 −26 src/test/java/graphql/annotations/GraphQLObjectTest.java
  79. +12 −4 src/test/java/graphql/annotations/RelayTest.java
  80. +84 −23 src/test/java/graphql/annotations/connection/GraphQLConnectionTest.java
  81. +7 −10 src/test/java/graphql/annotations/connection/GraphQLEnhancedConnectionTest.java
  82. +2 −1 src/test/java/graphql/annotations/connection/GraphQLSimpleConnectionTest.java
  83. +161 −0 src/test/java/graphql/annotations/directives/DirectiveSchemaVisitorTest.java
  84. +0 −527 src/test/java/graphql/annotations/directives/DirectiveWirerTest.java
  85. +9 −7 src/test/java/graphql/annotations/directives/DirectiveWiringMapRetrieverTest.java
  86. +101 −1 src/test/java/graphql/annotations/directives/creation/DirectiveArgumentCreatorTest.java
  87. +3 −1 src/test/java/graphql/annotations/directives/creation/DirectiveCreatorTest.java
  88. +49 −2 src/test/java/graphql/annotations/processor/retrievers/fieldBuilders/DeprecateBuilderTest.java
  89. +92 −50 src/test/java/graphql/annotations/processor/retrievers/fieldBuilders/DirectivesBuilderTest.java
  90. +1 −1 src/test/java/graphql/annotations/processor/typeFunctions/BigDecimalFunctionTests.java
  91. +4 −5 src/test/java/graphql/annotations/processor/typeFunctions/BigIntegerFunctionTests.java
  92. +3 −3 src/test/java/graphql/annotations/processor/typeFunctions/ByteFunctionTests.java
  93. +3 −3 src/test/java/graphql/annotations/processor/typeFunctions/CharFunctionTests.java
  94. +2 −2 src/test/java/graphql/annotations/processor/typeFunctions/DefaultTypeFunctionTest.java
  95. +3 −3 src/test/java/graphql/annotations/processor/typeFunctions/LongFunctionTests.java
  96. +3 −3 src/test/java/graphql/annotations/processor/typeFunctions/ShortFunctionTests.java
  97. +138 −0 src/test/java/graphql/annotations/processor/util/DirectiveJavaAnnotationUtilTest.java
34 changes: 34 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Build

on: [push, pull_request]

jobs:
validation:
name: "Gradle Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1
build:
needs:
- validation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'zulu'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: always() # always run even if the previous step fails
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Publish

on:
workflow_dispatch:
branches: [ master ]

jobs:
publish:
runs-on: ubuntu-latest
environment: prod
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'zulu'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Publish with Gradle
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
env:
MAVEN_CENTRAL_USERTOKEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERTOKEN_USERNAME }}
MAVEN_CENTRAL_USERTOKEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_USERTOKEN_PASSWORD }}
MAVEN_CENTRAL_PGP_KEY: ${{ secrets.MAVEN_CENTRAL_PGP_KEY }}
3 changes: 0 additions & 3 deletions .travis.yml

This file was deleted.

2 changes: 0 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Copyright 2016 Yurii Rashkovskii

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
157 changes: 135 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
![logo](polaris-iconsmalredl.png?raw=true)
![logo](graphql-annotations.png?raw=true)
# GraphQL-Java Annotations
[![Build Status](https://travis-ci.org/graphql-java/graphql-java-annotations.svg?branch=master)](https://travis-ci.org/graphql-java/graphql-java-annotations)
![build](https://github.com/Enigmatis/graphql-java-annotations/actions/workflows/build.yml/badge.svg)
[![Maven Central](https://img.shields.io/maven-central/v/io.github.graphql-java/graphql-java-annotations.svg?maxAge=3000)]()

[GraphQL-Java](https://github.com/andimarek/graphql-java) is a great library, but its syntax is a little bit verbose. This library offers an annotations-based
[GraphQL-Java](https://github.com/graphql-java/graphql-java) is a great library, but its syntax is a little bit verbose. This library offers an annotations-based
syntax for GraphQL schema definition.

If you would like to use a tool that creates a graphql spring boot server using graphql-java-annotations, you can view the [graphql-spring-annotations](https://github.com/yarinvak/graphql-spring-annotations) library.


## Table Of Contents
- [Getting Started](#getting-started)
@@ -35,7 +37,7 @@ syntax for GraphQL schema definition.

```groovy
dependencies {
compile "io.github.graphql-java:graphql-java-annotations:7.0"
compile "io.github.graphql-java:graphql-java-annotations:21.5"
}
```

@@ -45,7 +47,7 @@ dependencies {
<dependency>
<groupId>io.github.graphql-java</groupId>
<artifactId>graphql-java-annotations</artifactId>
<version>7.0</version>
<version>21.5</version>
</dependency>
```

@@ -248,7 +250,7 @@ public String field(@GraphQLDefaultValue(DefaultValue.class) String value) {
The `DefaultValue` class can define a `getInstance` method that will be called instead of the default constructor.

`@GraphQLDeprecate` and Java's `@Deprecated` can be used to specify a deprecated
field.
field or method.

### Custom data fetcher

@@ -377,7 +379,7 @@ public class HumanExtension {

## Type Inference

By default, standard GraphQL types (String, Integer, Long, Float, Boolean, Enum, List) will be inferred from Java types. Also, it will respect `@javax.validation.constraints.NotNull` annotation with respect to value's nullability, as well as `@GraphQLNonNull`
By default, standard GraphQL types (String, Integer, Long, Float, Boolean, Enum, List) will be inferred from Java types. Also, it will respect `@GraphQLNonNull` with respect to value's nullability

Stream type is also supported and treated as a list.

@@ -401,20 +403,94 @@ graphqlAnnotations.registerType(new UUIDTypeFunction())
You can also specify custom type function for any field with `@GraphQLType` annotation.

## Directives
You can wire your fields using directives with annotations.
We allow both defining directives using annotations, and wiring fields.
In GraphQL, you can add directives to your schema. Directive is a way of adding some logic to your schema or changing your schema.
For example, we can create a `@upper` directive, that if we add it to string fields in our schema, they will be transformed to upper cases (its an example, you need to implement it).

### Creating/Defining a ``GraphQLDirective``
In order to create a directive, you first have to create a class that the directive will be created from.
For example:
### Declaring a ``GraphQLDirective``
There are multiple ways to declare a directive in your schema using graphql-java-annotations.

#### Using a Java Annotation (recommended)
This is the most recommended way of creating a directive, because it is very easy to use later in your schema.
In order to declare a directive using a java annotation, you first have to create the java annotation, and annotate it with special annotations.

For example, we wish to create a directive that adds suffix to graphql fields.

```java
@GraphQLName("suffix")
@GraphQLDescription("this directive adds suffix to a string type")
@GraphQLDirectiveDefinition(wiring = SuffixWiring.class)
@DirectiveLocations({Introspection.DirectiveLocation.FIELD_DEFINITION, Introspection.DirectiveLocation.INTERFACE})
@Retention(RetentionPolicy.RUNTIME)
@interface Suffix {
@GraphQLName("suffixToAdd")
@GraphQLDescription("the suffix to add to your type")
boolean suffixToAdd() default true;
}
```

- must be annotated with `@GraphQLDirectiveDefinition` and to supply a wiring class to it (will be explained later)
- the name of the directive will be taken from the class name (`Suffix`) or if annotated with `@GraphQLName` - from its value
- the description is taken from the `@GraphQLDescription` annotation
- must be annotated with `@Retention` with a `RUNTIME` policy
- must be annotated with `@DirectiveLocations` in order to specify where we can put this directive on (for example - field definition, interface)

You can see that we also defined a ``sufixToAdd`` argument for the directive. We can also use `@GraphQLName` and `@GraphQLDescription` annotations in there.

In order to define a default value for the argument, use the `default` keyword like in the example.

After you created the class, you will be able to create the ``GraphQLDirective`` object using the following code:
```java
GraphQLDirective directive = graphqlAnnotations.directive(Suffix.class);
```

#### Using a method declaration
You can also declare an annotation via a method declaration inside some class.
For example, we will create a class of directive declarations:

```java
class DirectiveDeclarations{
@GraphQLName("upper")
@GraphQLDescription("upper")
@GraphQLDescription("upper directive")
@GraphQLDirectiveDefinition(wiring = UpperWiring.class)
@DirectiveLocations({Introspection.DirectiveLocation.FIELD_DEFINITION, Introspection.DirectiveLocation.INTERFACE})
public static class UpperDirective {
private boolean isActive = true;
public void upperDirective(@GraphQLName("isActive") @GraphQLDescription("is active") boolean isActive) {
}

@GraphQLName("suffix")
@GraphQLDescription("suffix directive")
@GraphQLDirectiveDefinition(wiring = SuffixWiring.class)
@DirectiveLocations({Introspection.DirectiveLocation.FIELD_DEFINITION, Introspection.DirectiveLocation.INTERFACE})
public void suffixDirective(@GraphQLName("suffix") @GraphQLDescription("the suffix") String suffix) {
}
}
```

- The methods has to be annotated with the `@GraphQLDirectiveDefinition` annotation, and to be supplied with a wiring class
- The methods has to be annotated with the `@DirectiveLocations` annotation
- Can be used: `@GraphQLName` and `@GraphQLDescription` - also inside method parameters (that will be transformed into arguments of the directive)

Notice that method params cannot have default values - so the directive arguments will not have default values.

In order to create the directives, you need to write:
```java
Set<GraphQLDirective> set = graphqlAnnotations.directives(DirectiveDeclarations.class);
```

#### Using a class declaration

Another way is to declare the directive using a class.

For example:

```java
@GraphQLName("upper")
@GraphQLDescription("upper")
@DirectiveLocations({Introspection.DirectiveLocation.FIELD_DEFINITION, Introspection.DirectiveLocation.INTERFACE})
@GraphQLDirectiveDefinition(wiring = UpperWiring.class)
public static class UpperDirective {
@GraphQLName("isActive")
private boolean isActive = true;
}
```

The name of the directive will be taken from the ``@GraphQLName`` annotation (if not specified, the name will be the class's name).
@@ -426,13 +502,14 @@ You can also use ``@GraphQLName`` and ``@GraphQLDescription`` annotations on the

After you created the class, you will be able to create the ``GraphQLDirective`` object using the following code:
```java
graphqlAnnotations.directive(UpperDirective.class);
GraphQLDirective directive = graphqlAnnotations.directive(UpperDirective.class);
```

### Wiring with directives
Using directives you will be able to wire fields and more, for example, changing the data fetchers of the fields.
### Wiring with the directives
In order to define the wiring logic (what will be executed on top of the graphql type annotated with the directive) we have to create wiring class.

In order to define a wiring functionality, you have to create a Wiring class matching one of your directives. For example:

In order to define a wiring functionality, you have to create a Wiring class matching one of you directives. For example:
```java
public class UpperWiring implements AnnotationsDirectiveWiring {
@Override
@@ -450,20 +527,56 @@ public class UpperWiring implements AnnotationsDirectiveWiring {
}
```

In this example we wrap the data fetcher of the field in order to make the resolved value upper case.

You can also use the `field.transform` method in order to change some of the field's properties.

This class turns your string field to upper case if the directive argument "isActive" is set to true.
Now, you have to wire the field itself:

Put this class inside the `@GraphQLDirectiveDefinition(wiring = UpperWiring.class)` annotation where you declare your directive (see directive declaration section above).

### Using the directives

There are 2 ways of using the directives in your graphql types.

#### Using the directive java annotation (RECOMMENDED)
This way only works if you declared your directive as a java annotation.
In the example above, we created the `@Suffix` annotation as a directive.
So now we can put it on top of our graphql field.

For example:

```java
@GraphQLField
@GraphQLDirectives(@Directive(name = "upperCase", wiringClass = UpperWiring.class, argumentsValues = {"true"}))
public static String name() {
@Suffix(suffixToAdd = " is cool")
public String name(){
return "yarin";
}
```

Now every time the field will be executed, the suffix " is cool" will be added to it.
You can also use directive on field arguments, interfaces, etc.

#### Using `@GraphQLDirectives` annotation
This way works in the 3 methods of declaring directives, but is less recommended because its more complicated and not so nice.
You can annotate your graphql field with the `@GraphQLDirectives` annotation and supply it with the directives to use and the arguments values you want to supply.

For example:

```java
@GraphQLField
@GraphQLDirectives(@Directive(name = "upperCase", argumentsValues = {"true"}))
public String name() {
return "yarin";
}
```

We now wired the field "name" - so it will turn upper case when calling the field.
The ``Directive`` annotations requires the name of the directive, the wiring class (the ``UpperWiring`` class defined earlier), and the values of the arguments. If an argument has a default value, you don't have to supply a value in the arguments values.

Notice that in any way, the directives are sequential, so the first annotated directive will happen before the second one.
If put both java annotation directive and `@GraphQLDirectives` annotation directives, the java annotation directive will be applied first.

## Relay support

### Mutations
18 changes: 18 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
RELEASE DOCUMENTATION
---------------------

Here are the steps to produce a release of the project:

1. Check the gradle.properties file to make sure that the version number has been updated
2. In the Github release UI, create a new tag with the following naming convention vXX.X and make sure you generate the release notes.
3. Create the release using the create release button
4. Wait for the build action to complete successfully
5. Launch the "Publish" action manually and wait for it to complete
6. Check at the following URL that the new release was deployed :

https://repo1.maven.org/maven2/io/github/graphql-java/graphql-java-annotations/

It might take some time for the release to appear
7. Update this document if anything was missing or wasn't clear
8. Once everything is properly deployed, update the gradle.properties file to the next planned version, either directly (if that is the only change), or in a PR if other changes need to be done at the same time.
9. Announce the release on your favorite communication channels.
20 changes: 0 additions & 20 deletions azure-pipelines.yml

This file was deleted.

2 changes: 2 additions & 0 deletions bnd.bnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-exportcontents: graphql.annotations.*
-nouses: true
Loading