Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5fde099
Update to next development version: 5.5.1-SNAPSHOT
kobylynskyi Sep 11, 2022
ef8baaf
Upgrade versions of SBT project (#1001)
jxnu-liguobin Sep 11, 2022
a0d8244
Added support for annotations in generated kotlin operations #1002 (#…
msl-at-fcb Sep 13, 2022
ec6d30d
Fix failing tests on some OS (#1027)
esfomeado Feb 19, 2023
76e0471
Fix generation of Interface when return type of the method has a list…
kobylynskyi Feb 20, 2023
b6dfc63
Generate Jackson annotations for interfaces #1033 #1034
esfomeado Feb 21, 2023
e06d69b
Ability to combine multiple response projections #985 (#1031)
kobylynskyi Feb 22, 2023
bea0364
New config to specify custom @Generated annotation #1016 (#1036)
kobylynskyi Feb 23, 2023
11c9d5b
Bump version to 5.6.0-SNAPSHOT (#1038)
kobylynskyi Feb 26, 2023
8f4dee2
Fix line separator tests (#1039)
kobylynskyi Feb 26, 2023
e6465c3
Save kotlin nullable sign for custom type mapping and apiReturnType #…
romash1408 Feb 26, 2023
764925a
New config to generate only no-args constructor #1017 (#1037)
kobylynskyi Feb 26, 2023
2af7f68
Bump to release version 5.6.0
kobylynskyi Feb 26, 2023
b28cd8b
Merge branch 'master' into develop
kobylynskyi Feb 28, 2023
cafad12
Merge branch 'master' into develop
kobylynskyi Feb 28, 2023
dd0dbdc
Update to next development version: 5.6.1-SNAPSHOT
kobylynskyi Feb 28, 2023
571b22a
Scala: fix deprecated APIs, support generateSealedInterfaces (#1042)
jxnu-liguobin Mar 16, 2023
3314b53
Mitigate CVE-2022-37734 by updating graphql and jackson dependencies …
upendrao Mar 16, 2023
0c3674b
fix: updated unit test with increased max query tokens (#1047)
upendrao Mar 16, 2023
58f1061
Add resolver argument annotation on parameterized field resolvers (#1…
clement-buchart Mar 18, 2023
73a342e
Add test to show how to generate nullable types instead of primitives…
kobylynskyi Mar 18, 2023
134bc89
New config to generate models with public fields #864 (#1049)
kobylynskyi Mar 19, 2023
0b212e6
Support overriding FreeMarker templates #860 (#1048)
velo Mar 19, 2023
52eb425
Fix reviewdog styling issues
kobylynskyi Mar 19, 2023
569fba3
Change output message
kobylynskyi Mar 22, 2023
e8f7cd6
Change customTemplates Map key to be type String (#1052)
velo Mar 22, 2023
d2b2f08
Update README.md
kobylynskyi Mar 22, 2023
b81740f
Merge remote-tracking branch 'origin/develop' into develop
kobylynskyi Mar 22, 2023
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
5 changes: 5 additions & 0 deletions .github/workflows/check-code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

# brew install sbt; cd graphql-java-codegen-sbt-plugin; sbt fmt or sbt check
- name: Check Scala Code Style
working-directory: plugins/sbt/graphql-java-codegen-sbt-plugin
run: sbt check

- name: Check Code Style
env:
WORKDIR: ./
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ build
modules.xml
.idea/misc.xml
*.ipr

bin/
.classpath
.project
.settings/

### Maven ###
target/
Expand Down
6 changes: 2 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ Please follow the steps below in order to make the changes:
./gradlew -p plugins/gradle/graphql-java-codegen-gradle-plugin clean build

# Build Maven plugin
cd plugins/maven/graphql-java-codegen-maven-plugin
mvn clean verify
mvn clean verify -f plugins/maven/graphql-java-codegen-maven-plugin/pom.xml
```

9. Make changes to the plugin code
Expand All @@ -48,8 +47,7 @@ Please follow the steps below in order to make the changes:
./gradlew -p plugins/gradle/graphql-java-codegen-gradle-plugin clean build publishToMavenLocal

# Install Maven plugin
cd plugins/maven/graphql-java-codegen-maven-plugin
mvn clean install
mvn clean install -f plugins/maven/graphql-java-codegen-maven-plugin/pom.xml
```

11. Make sure that `example` projects are compiling and running.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# GraphQL Codegen #

[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/donate/?business=V5VX4NAQT7TW8&no_recurring=0&item_name=to+help+maintaining+GraphQL+Java+Codegen+project+🙏&currency_code=USD)

![Build](https://github.com/kobylynskyi/graphql-java-codegen/workflows/Build/badge.svg)
[![Discussions](https://img.shields.io/badge/github-discussions-green)](https://github.com/kobylynskyi/graphql-java-codegen/discussions)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
id "org.sonarqube" version "3.2.0"
}

def graphqlCodegenVersion = '5.6.0' // This variable used in the automatic release process
def graphqlCodegenVersion = '5.6.1-SNAPSHOT' // This variable used in the automatic release process

group = "io.github.kobylynskyi"
version = graphqlCodegenVersion
Expand All @@ -21,8 +21,8 @@ repositories {

dependencies {
compileOnly "org.freemarker:freemarker:2.3.31"
compileOnly "com.graphql-java:graphql-java:16.2"
compileOnly "com.fasterxml.jackson.core:jackson-databind:2.13.3"
compileOnly "com.graphql-java:graphql-java:20.0"
compileOnly "com.fasterxml.jackson.core:jackson-databind:2.14.2"
compileOnly "com.typesafe:config:1.4.1"

testImplementation "org.junit.jupiter:junit-jupiter-api:5.7.1"
Expand Down
130 changes: 66 additions & 64 deletions docs/codegen-options.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions plugins/gradle/example-client-kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import io.github.kobylynskyi.graphql.codegen.gradle.GraphQLCodegenGradleTask
plugins {
id "java"
id "org.jetbrains.kotlin.jvm" version "1.6.21"
id "io.github.kobylynskyi.graphql.codegen" version "5.6.0"
id "io.github.kobylynskyi.graphql.codegen" version "5.6.1-SNAPSHOT"
}

def graphqlCodegenClientKotlinVersion = '5.6.0' // Variable used in the automatic release process
def graphqlCodegenClientKotlinVersion = '5.6.1-SNAPSHOT' // Variable used in the automatic release process

group = 'io.github.dreamylost'
version = graphqlCodegenClientKotlinVersion
Expand All @@ -29,7 +29,7 @@ repositories {


dependencies {
implementation "io.github.kobylynskyi:graphql-java-codegen:5.6.0"
implementation "io.github.kobylynskyi:graphql-java-codegen:5.6.1-SNAPSHOT"
implementation "javax.validation:validation-api:2.0.1.Final"
implementation "com.squareup.okhttp3:okhttp:4.2.2"
implementation "com.fasterxml.jackson.core:jackson-core:2.13.3"
Expand Down
4 changes: 2 additions & 2 deletions plugins/gradle/example-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {

// use the latest available version:
// https://plugins.gradle.org/plugin/io.github.kobylynskyi.graphql.codegen
id "io.github.kobylynskyi.graphql.codegen" version "5.6.0"
id "io.github.kobylynskyi.graphql.codegen" version "5.6.1-SNAPSHOT"
}

mainClassName = "io.github.kobylynskyi.order.Application"
Expand All @@ -22,7 +22,7 @@ dependencies {

// use the latest available version:
// https://search.maven.org/artifact/io.github.kobylynskyi/graphql-java-codegen
implementation "io.github.kobylynskyi:graphql-java-codegen:5.6.0"
implementation "io.github.kobylynskyi:graphql-java-codegen:5.6.1-SNAPSHOT"

implementation "org.apache.httpcomponents:httpclient:4.5.13"
implementation "javax.validation:validation-api:2.0.1.Final"
Expand Down
2 changes: 1 addition & 1 deletion plugins/gradle/example-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
//
// use the latest available version:
// https://plugins.gradle.org/plugin/io.github.kobylynskyi.graphql.codegen
id "io.github.kobylynskyi.graphql.codegen" version "5.6.0"
id "io.github.kobylynskyi.graphql.codegen" version "5.6.1-SNAPSHOT"
}

mainClassName = "io.github.kobylynskyi.product.Application"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ apply plugin: "java"
apply plugin: "idea"
apply plugin: "maven-publish"

def graphqlCodegenGradlePluginVersion = '5.6.0' // This variable used in the automatic release process
def graphqlCodegenGradlePluginVersion = '5.6.1-SNAPSHOT' // This variable used in the automatic release process

group = "io.github.kobylynskyi"
version = graphqlCodegenGradlePluginVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class GraphQLCodegenGradleTask extends DefaultTask implements GraphQLCode

private Map<String, String> customTypesMapping = new HashMap<>();
private Map<String, List<String>> customAnnotationsMapping = new HashMap<>();
private Map<String, String> customTemplates = new HashMap<>();
private Map<String, List<String>> directiveAnnotationsMapping = new HashMap<>();
private String packageName;
private String apiPackageName;
Expand Down Expand Up @@ -85,6 +86,7 @@ public class GraphQLCodegenGradleTask extends DefaultTask implements GraphQLCode
private Boolean generateJacksonTypeIdResolver = MappingConfigConstants.DEFAULT_GENERATE_JACKSON_TYPE_ID_RESOLVER;
private Boolean addGeneratedAnnotation = MappingConfigConstants.DEFAULT_ADD_GENERATED_ANNOTATION;
private Boolean generateNoArgsConstructorOnly = MappingConfigConstants.DEFAULT_GENERATE_NOARGS_CONSTRUCTOR_ONLY;
private Boolean generateModelsWithPublicFields = MappingConfigConstants.DEFAULT_GENERATE_MODELS_WITH_PUBLIC_FIELDS;
private String generatedAnnotation;
private Set<String> fieldsWithResolvers = new HashSet<>();
private Set<String> fieldsWithoutResolvers = new HashSet<>();
Expand Down Expand Up @@ -132,8 +134,8 @@ public void generate() throws Exception {
mappingConfig.setPackageName(packageName);
mappingConfig.setCustomTypesMapping(
customTypesMapping != null ? customTypesMapping : new HashMap<>());
mappingConfig.setCustomAnnotationsMapping(
customAnnotationsMapping != null ? customAnnotationsMapping : new HashMap<>());
mappingConfig.setCustomTemplates(
customTemplates != null ? customTemplates : new HashMap<>());
mappingConfig.setDirectiveAnnotationsMapping(
directiveAnnotationsMapping != null ? directiveAnnotationsMapping : new HashMap<>());
mappingConfig.setApiNameSuffix(apiNameSuffix);
Expand All @@ -157,6 +159,7 @@ public void generate() throws Exception {
mappingConfig.setGenerateApisWithThrowsException(generateApisWithThrowsException);
mappingConfig.setGenerateJacksonTypeIdResolver(generateJacksonTypeIdResolver);
mappingConfig.setGenerateNoArgsConstructorOnly(generateNoArgsConstructorOnly);
mappingConfig.setGenerateModelsWithPublicFields(generateModelsWithPublicFields);
mappingConfig.setAddGeneratedAnnotation(addGeneratedAnnotation);
mappingConfig.setGeneratedAnnotation(generatedAnnotation);
mappingConfig.setApiReturnType(apiReturnType);
Expand Down Expand Up @@ -331,6 +334,17 @@ public void setCustomTypesMapping(Map<String, String> customTypesMapping) {
this.customTypesMapping = customTypesMapping;
}

@Input
@Optional
@Override
public Map<String, String> getCustomTemplates() {
return customTemplates;
}

public void setCustomTemplates(Map<String, String> customTemplates) {
this.customTemplates = customTemplates;
}

@Input
@Optional
@Override
Expand Down Expand Up @@ -695,6 +709,17 @@ public void setGenerateNoArgsConstructorOnly(Boolean generateNoArgsConstructorOn
this.generateNoArgsConstructorOnly = generateNoArgsConstructorOnly;
}

@Input
@Optional
@Override
public Boolean isGenerateModelsWithPublicFields() {
return generateModelsWithPublicFields;
}

public void setGenerateModelsWithPublicFields(Boolean generateModelsWithPublicFields) {
this.generateModelsWithPublicFields = generateModelsWithPublicFields;
}

@Input
@Optional
@Override
Expand Down
2 changes: 1 addition & 1 deletion plugins/maven/example-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>io.github.kobylynskyi</groupId>
<artifactId>graphql-codegen-maven-plugin-example-client</artifactId>
<version>5.6.0</version>
<version>5.6.1-SNAPSHOT</version>
<name>graphql-codegen-maven-plugin-example-client</name>

<build>
Expand Down
2 changes: 1 addition & 1 deletion plugins/maven/example-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>io.github.kobylynskyi</groupId>
<artifactId>graphql-codegen-maven-plugin-example-server</artifactId>
<version>5.6.0</version>
<version>5.6.1-SNAPSHOT</version>
<name>graphql-codegen-maven-plugin-example-server</name>

<build>
Expand Down
4 changes: 2 additions & 2 deletions plugins/maven/graphql-java-codegen-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>io.github.kobylynskyi</groupId>
<artifactId>graphql-codegen-maven-plugin</artifactId>
<version>5.6.0</version>
<version>5.6.1-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<name>graphql-codegen-maven-plugin</name>
Expand Down Expand Up @@ -72,7 +72,7 @@
<version.maven-gpg-plugin>3.0.1</version.maven-gpg-plugin>
<version.maven-shared-utils>3.3.4</version.maven-shared-utils>

<version.graphql-java-codegen>5.6.0</version.graphql-java-codegen>
<version.graphql-java-codegen>5.6.1-SNAPSHOT</version.graphql-java-codegen>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public class GraphQLCodegenMojo extends AbstractMojo implements GraphQLCodegenCo
@Parameter
private Map<String, Properties> customAnnotationsMapping;

@Parameter
private Map<String, String> customTemplates;

@Parameter
private Map<String, Properties> directiveAnnotationsMapping;

Expand Down Expand Up @@ -158,6 +161,9 @@ public class GraphQLCodegenMojo extends AbstractMojo implements GraphQLCodegenCo
@Parameter(defaultValue = MappingConfigConstants.DEFAULT_GENERATE_NOARGS_CONSTRUCTOR_ONLY_STRING)
private boolean generateNoArgsConstructorOnly;

@Parameter(defaultValue = MappingConfigConstants.DEFAULT_GENERATE_MODELS_WITH_PUBLIC_FIELDS_STRING)
private boolean generateModelsWithPublicFields;

@Parameter
private String generatedAnnotation;

Expand Down Expand Up @@ -243,6 +249,7 @@ public void execute() throws MojoExecutionException {
MappingConfig mappingConfig = new MappingConfig();
mappingConfig.setPackageName(packageName);
mappingConfig.setCustomTypesMapping(convertToMap(customTypesMapping));
mappingConfig.setCustomTemplates(customTemplates);
mappingConfig.setCustomAnnotationsMapping(convertToListsMap(customAnnotationsMapping));
mappingConfig.setDirectiveAnnotationsMapping(convertToListsMap(directiveAnnotationsMapping));
mappingConfig.setApiNameSuffix(apiNameSuffix);
Expand Down Expand Up @@ -275,6 +282,7 @@ public void execute() throws MojoExecutionException {
mappingConfig.setAddGeneratedAnnotation(addGeneratedAnnotation);
mappingConfig.setGeneratedAnnotation(generatedAnnotation);
mappingConfig.setGenerateNoArgsConstructorOnly(generateNoArgsConstructorOnly);
mappingConfig.setGenerateModelsWithPublicFields(generateModelsWithPublicFields);
mappingConfig.setFieldsWithResolvers(mapToHashSet(fieldsWithResolvers));
mappingConfig.setFieldsWithoutResolvers(mapToHashSet(fieldsWithoutResolvers));
mappingConfig.setRelayConfig(relayConfig);
Expand Down Expand Up @@ -684,6 +692,11 @@ public Boolean isGenerateNoArgsConstructorOnly() {
return generateNoArgsConstructorOnly;
}

@Override
public Boolean isGenerateModelsWithPublicFields() {
return generateModelsWithPublicFields;
}

public ParentInterfacesConfig getParentInterfaces() {
return parentInterfaces;
}
Expand Down Expand Up @@ -728,4 +741,12 @@ private static Map<String, String> convertToMap(Properties properties) {
return result;
}

@Override
public Map<String, String> getCustomTemplates() {
if (customTemplates == null) {
return new HashMap<>();
}
return customTemplates;
}

}
23 changes: 23 additions & 0 deletions plugins/sbt/graphql-java-codegen-sbt-plugin/.scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version = "3.6.1"
runner.dialect = scala213
maxColumn = 120
align.preset = more
lineEndings = preserve
align.stripMargin = false
docstrings.style = AsteriskSpace
docstrings.oneline = keep
continuationIndent.defnSite = 2
danglingParentheses.preset = true
spaces {
inImportCurlyBraces = true
}
indentOperator.exemptScope = aloneArgOrBody
includeCurlyBraceInSelectChains = false
align.openParenDefnSite = false
optIn.annotationNewlines = true
rewrite.rules = [SortImports, RedundantBraces]
rewriteTokens = {
"⇒": "=>"
"→": "->"
"←": "<-"
}
11 changes: 0 additions & 11 deletions plugins/sbt/graphql-java-codegen-sbt-plugin/.scalariform.conf

This file was deleted.

25 changes: 13 additions & 12 deletions plugins/sbt/graphql-java-codegen-sbt-plugin/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ jValidationVersion := "2.0.1.Final"

// keep version is equals with parent project `graphql-java-codegen`.
// Plugin don't need to care about the scala version, just the SBT version.
lazy val `graphql-codegen-sbt-plugin` = Project(id = "graphql-codegen-sbt-plugin", base = file(".")).
enablePlugins(SbtPlugin, BuildInfoPlugin).
settings(Publishing.publishSettings).
settings(
sbtPlugin := true,
lazy val `graphql-codegen-sbt-plugin` = Project(id = "graphql-codegen-sbt-plugin", base = file("."))
.enablePlugins(SbtPlugin, BuildInfoPlugin)
.settings(Publishing.publishSettings)
.settings(
sbtPlugin := true,
scriptedBufferLog := false,
commands ++= Commands.value,
scriptedLaunchOpts += s"-Dplugin.version=${version.value}",
scalacOptions += "-target:jvm-1.8",
releaseIgnoreUntrackedFiles := true,
Expand All @@ -31,12 +32,12 @@ lazy val `graphql-codegen-sbt-plugin` = Project(id = "graphql-codegen-sbt-plugin
pushChanges
),
libraryDependencies ++= Seq(
"io.github.kobylynskyi" % "graphql-java-codegen" % (version in ThisBuild).value,
"org.freemarker" % "freemarker" % "2.3.31",
"com.graphql-java" % "graphql-java" % "16.2",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.12.1",
"com.typesafe" % "config" % "1.4.2"
"io.github.kobylynskyi" % "graphql-java-codegen" % (ThisBuild / version).value,
"org.freemarker" % "freemarker" % "2.3.31",
"com.graphql-java" % "graphql-java" % "16.2",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.12.1",
"com.typesafe" % "config" % "1.4.2"
),
buildInfoKeys := Seq[BuildInfoKey](name, version, sbtVersion, jValidationVersion),
buildInfoKeys := Seq[BuildInfoKey](name, version, sbtVersion, jValidationVersion),
buildInfoPackage := "io.github.dreamylost.graphql.codegen"
)
)
20 changes: 20 additions & 0 deletions plugins/sbt/graphql-java-codegen-sbt-plugin/project/Commands.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import sbt.Command

/** @author
* 梦境迷离
* @since 2022/1/15
* @version 1.0
*/
object Commands {

val FmtSbtCommand = Command.command("fmt")(state => "scalafmtSbt" :: "scalafmtAll" :: state)

val FmtSbtCheckCommand =
Command.command("check")(state => "scalafmtSbtCheck" :: "scalafmtCheckAll" :: state)

val value = Seq(
FmtSbtCommand,
FmtSbtCheckCommand
)

}
Loading