You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2020/03/10 19:05:13 UTC
[camel-quarkus] 01/02: Add GraphQL extension
This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 7133574f527e6d80bb0c35078ab58ddf226a1125
Author: James Netherton <ja...@gmail.com>
AuthorDate: Tue Mar 10 11:22:02 2020 +0000
Add GraphQL extension
Fixes #801
---
.github/workflows/pr-build.yaml | 1 +
docs/modules/ROOT/pages/extensions/graphql.adoc | 29 +++++
.../pages/list-of-camel-quarkus-extensions.adoc | 5 +-
extensions/graphql/deployment/pom.xml | 79 +++++++++++++
.../graphql/deployment/GraphQLProcessor.java | 51 +++++++++
extensions/graphql/pom.xml | 50 +++++++++
extensions/graphql/runtime/pom.xml | 86 +++++++++++++++
.../component/graphql/CamelGraphQLConfig.java | 39 +++++++
.../main/resources/META-INF/quarkus-extension.yaml | 27 +++++
extensions/pom.xml | 1 +
extensions/readme.adoc | 5 +-
integration-tests/graphql/pom.xml | 122 +++++++++++++++++++++
.../component/graphql/it/GraphQLResource.java | 107 ++++++++++++++++++
.../quarkus/component/graphql/it/model/Book.java | 56 ++++++++++
.../src/main/resources/application.properties | 18 +++
.../src/main/resources/graphql/bookQuery.graphql | 9 ++
.../src/main/resources/graphql/schema.graphql | 28 +++++
.../quarkus/component/graphql/it/GraphQLIT.java | 24 ++++
.../quarkus/component/graphql/it/GraphQLTest.java | 39 +++++++
integration-tests/pom.xml | 1 +
pom.xml | 1 +
poms/bom-deployment/pom.xml | 5 +
poms/bom/pom.xml | 10 ++
23 files changed, 791 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/pr-build.yaml b/.github/workflows/pr-build.yaml
index 8784cca..f53320e 100644
--- a/.github/workflows/pr-build.yaml
+++ b/.github/workflows/pr-build.yaml
@@ -150,6 +150,7 @@ jobs:
compression
dozer
ftp
+ graphql
mail
mustache
pdf
diff --git a/docs/modules/ROOT/pages/extensions/graphql.adoc b/docs/modules/ROOT/pages/extensions/graphql.adoc
new file mode 100644
index 0000000..060bac0
--- /dev/null
+++ b/docs/modules/ROOT/pages/extensions/graphql.adoc
@@ -0,0 +1,29 @@
+[[graphql]]
+= GraphQL Extension
+
+*Since Camel Quarkus 1.0.0-M5*
+
+The GraphQL component is a GraphQL client that communicates over HTTP and supports queries and mutations.
+
+Maven users will need to add the following dependency to their `pom.xml` for this extension.
+
+[source,xml]
+------------------------------------------------------------
+<dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-graphql</artifactId>
+</dependency>
+------------------------------------------------------------
+
+== Usage
+
+The extension provides support for the Camel https://camel.apache.org/components/latest/graphql-component.html[GraphQL Component].
+
+=== Configuration
+
+When configuring `graphql` endpoints to reference query files from the classpath, set the following configuration property to ensure that they are available in native mode.
+
+[source,properties]
+----
+quarkus.camel.graphql.query-files = queries.graphql, classpath:graphql/my-query.graphql
+----
diff --git a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
index 9fd7ab6..c90bf88 100644
--- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
+++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
@@ -18,7 +18,7 @@ In case you are missing some Camel feature in the list:
== Camel Components
// components: START
-Number of Camel components: 74 in 64 JAR artifacts (0 deprecated)
+Number of Camel components: 75 in 65 JAR artifacts (0 deprecated)
[width="100%",cols="4,1,5",options="header"]
|===
@@ -123,6 +123,9 @@ Number of Camel components: 74 in 64 JAR artifacts (0 deprecated)
| link:https://camel.apache.org/components/latest/ftps-component.html[FTPS] (camel-quarkus-ftp) +
`ftps:host:port/directoryName` | 1.0.0-M1 | The \ftps (FTP secure SSL/TLS) component is used for uploading or downloading files from FTP servers.
+| xref:extensions/graphql.adoc[GraphQL] (camel-quarkus-graphql) +
+`graphql:httpUri` | 1.0.0-M5 | A Camel GraphQL Component
+
| xref:extensions/http.adoc[HTTP] (camel-quarkus-http) +
`http:httpUri` | 1.0.0-M3 | For calling out to external HTTP servers using Apache HTTP Client 4.x.
diff --git a/extensions/graphql/deployment/pom.xml b/extensions/graphql/deployment/pom.xml
new file mode 100644
index 0000000..6c3cab4
--- /dev/null
+++ b/extensions/graphql/deployment/pom.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-graphql-parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-graphql-deployment</artifactId>
+ <name>Camel Quarkus :: GraphQL :: Deployment</name>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-httpclient-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-graphql</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/extensions/graphql/deployment/src/main/java/org/apache/camel/quarkus/component/graphql/deployment/GraphQLProcessor.java b/extensions/graphql/deployment/src/main/java/org/apache/camel/quarkus/component/graphql/deployment/GraphQLProcessor.java
new file mode 100644
index 0000000..8cec413
--- /dev/null
+++ b/extensions/graphql/deployment/src/main/java/org/apache/camel/quarkus/component/graphql/deployment/GraphQLProcessor.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.graphql.deployment;
+
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import org.apache.camel.quarkus.component.graphql.CamelGraphQLConfig;
+
+class GraphQLProcessor {
+
+ private static final String FEATURE = "camel-graphql";
+
+ @BuildStep
+ FeatureBuildItem feature() {
+ return new FeatureBuildItem(FEATURE);
+ }
+
+ @BuildStep
+ ExtensionSslNativeSupportBuildItem activateSslNativeSupport() {
+ return new ExtensionSslNativeSupportBuildItem(FEATURE);
+ }
+
+ @BuildStep
+ void nativeImageResources(BuildProducer<NativeImageResourceBuildItem> nativeImage, CamelGraphQLConfig config) {
+ if (!config.queryFiles.isPresent()) {
+ return;
+ }
+
+ config.queryFiles.get()
+ .stream()
+ .map(scriptFile -> new NativeImageResourceBuildItem(scriptFile.replace("classpath:", "")))
+ .forEach(nativeImage::produce);
+ }
+}
diff --git a/extensions/graphql/pom.xml b/extensions/graphql/pom.xml
new file mode 100644
index 0000000..8d6f914
--- /dev/null
+++ b/extensions/graphql/pom.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-build-parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../../poms/build-parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-graphql-parent</artifactId>
+ <name>Camel Quarkus :: GraphQL</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>deployment</module>
+ <module>runtime</module>
+ </modules>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-bom-deployment</artifactId>
+ <version>${quarkus.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+</project>
diff --git a/extensions/graphql/runtime/pom.xml b/extensions/graphql/runtime/pom.xml
new file mode 100644
index 0000000..3be7baa
--- /dev/null
+++ b/extensions/graphql/runtime/pom.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-graphql-parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-graphql</artifactId>
+ <name>Camel Quarkus :: GraphQL :: Runtime</name>
+
+ <properties>
+ <firstVersion>1.0.0-M5</firstVersion>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-httpclient</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-graphql</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-bootstrap-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/extensions/graphql/runtime/src/main/java/org/apache/camel/quarkus/component/graphql/CamelGraphQLConfig.java b/extensions/graphql/runtime/src/main/java/org/apache/camel/quarkus/component/graphql/CamelGraphQLConfig.java
new file mode 100644
index 0000000..081a3f2
--- /dev/null
+++ b/extensions/graphql/runtime/src/main/java/org/apache/camel/quarkus/component/graphql/CamelGraphQLConfig.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.graphql;
+
+import java.util.List;
+import java.util.Optional;
+
+import io.quarkus.runtime.annotations.ConfigItem;
+import io.quarkus.runtime.annotations.ConfigPhase;
+import io.quarkus.runtime.annotations.ConfigRoot;
+
+@ConfigRoot(name = "camel.graphql", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED)
+public class CamelGraphQLConfig {
+
+ /**
+ * A comma separated list of paths to files containing GraphQL queries for use by GraphQL endpoints.
+ *
+ * Query files that only need to be accessible from the classpath should be specified on this property.
+ *
+ * Paths can either be schemeless (E.g graphql/my-query.graphql) or be prefixed with the classpath: URI scheme (E.g
+ * classpath:graphql/my-query.graphql). Other URI schemes are not supported.
+ */
+ @ConfigItem
+ public Optional<List<String>> queryFiles;
+}
diff --git a/extensions/graphql/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/graphql/runtime/src/main/resources/META-INF/quarkus-extension.yaml
new file mode 100644
index 0000000..bfde4b2
--- /dev/null
+++ b/extensions/graphql/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -0,0 +1,27 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+---
+name: "Camel Quarkus GraphQL"
+description: "Camel Quarkus GraphQL Support"
+metadata:
+ keywords:
+ - "camel"
+ - "graphql"
+ guide: "https://quarkus.io/guides/camel"
+ categories:
+ - "integration"
\ No newline at end of file
diff --git a/extensions/pom.xml b/extensions/pom.xml
index c9a2ca8..655aa41 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -79,6 +79,7 @@
<module>file</module>
<module>file-watch</module>
<module>ftp</module>
+ <module>graphql</module>
<module>gson</module>
<module>http</module>
<module>hystrix</module>
diff --git a/extensions/readme.adoc b/extensions/readme.adoc
index 8066a63..57adb00 100644
--- a/extensions/readme.adoc
+++ b/extensions/readme.adoc
@@ -5,7 +5,7 @@ Apache Camel Quarkus supports the following Camel artifacts as Quarkus Extension
== Camel Components
// components: START
-Number of Camel components: 74 in 64 JAR artifacts (0 deprecated)
+Number of Camel components: 75 in 65 JAR artifacts (0 deprecated)
[width="100%",cols="4,1,5",options="header"]
|===
@@ -110,6 +110,9 @@ Number of Camel components: 74 in 64 JAR artifacts (0 deprecated)
| link:https://camel.apache.org/components/latest/ftps-component.html[FTPS] (camel-quarkus-ftp) +
`ftps:host:port/directoryName` | 1.0.0-M1 | The \ftps (FTP secure SSL/TLS) component is used for uploading or downloading files from FTP servers.
+| xref:extensions/graphql.adoc[GraphQL] (camel-quarkus-graphql) +
+`graphql:httpUri` | 1.0.0-M5 | A Camel GraphQL Component
+
| xref:extensions/http.adoc[HTTP] (camel-quarkus-http) +
`http:httpUri` | 1.0.0-M3 | For calling out to external HTTP servers using Apache HTTP Client 4.x.
diff --git a/integration-tests/graphql/pom.xml b/integration-tests/graphql/pom.xml
new file mode 100644
index 0000000..d6406d2
--- /dev/null
+++ b/integration-tests/graphql/pom.xml
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-tests</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-quarkus-integration-test-graphql</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: GraphQL</name>
+ <description>Integration tests for Camel Quarkus GraphQL extension</description>
+
+ <properties>
+ <!-- mvnd, a.k.a. Maven Daemon: https://github.com/gnodet/mvnd -->
+ <!-- The following rule tells mvnd to build the listed deployment modules before this module. -->
+ <!-- This is important because mvnd builds modules in parallel by default. The deployment modules are not -->
+ <!-- explicit dependencies of this module in the Maven sense, although they are required by the Quarkus Maven plugin. -->
+ <!-- Please update rule whenever you change the dependencies of this module by running -->
+ <!-- mvn process-resources -Pformat from the root directory -->
+ <mvnd.builder.rule>camel-quarkus-graphql-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-graphql</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-vertx-graphql</artifactId>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.rest-assured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>native</id>
+ <activation>
+ <property>
+ <name>native</name>
+ </property>
+ </activation>
+ <properties>
+ <quarkus.package.type>native</quarkus.package.type>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ <configuration>
+ <systemProperties>
+ <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/integration-tests/graphql/src/main/java/org/apache/camel/quarkus/component/graphql/it/GraphQLResource.java b/integration-tests/graphql/src/main/java/org/apache/camel/quarkus/component/graphql/it/GraphQLResource.java
new file mode 100644
index 0000000..1f85652
--- /dev/null
+++ b/integration-tests/graphql/src/main/java/org/apache/camel/quarkus/component/graphql/it/GraphQLResource.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.graphql.it;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionStage;
+
+import javax.enterprise.event.Observes;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import graphql.GraphQL;
+import graphql.schema.DataFetcher;
+import graphql.schema.DataFetchingEnvironment;
+import graphql.schema.GraphQLSchema;
+import graphql.schema.idl.RuntimeWiring;
+import graphql.schema.idl.SchemaGenerator;
+import graphql.schema.idl.SchemaParser;
+import graphql.schema.idl.TypeDefinitionRegistry;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.handler.graphql.GraphQLHandler;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.quarkus.component.graphql.it.model.Book;
+import org.apache.camel.util.json.JsonObject;
+
+@Path("/graphql")
+public class GraphQLResource {
+
+ private static final List<Book> BOOKS = Arrays.asList(
+ new Book("book-1", "Harry Potter and the Philosophers Stone", "author-1"),
+ new Book("book-2", "Moby Dick", "author-2"),
+ new Book("book-3", "Interview with the vampire", "author-3"));
+
+ @Inject
+ ProducerTemplate producerTemplate;
+
+ public void setupRouter(@Observes Router router) {
+ SchemaParser schemaParser = new SchemaParser();
+ TypeDefinitionRegistry typeDefinitionRegistry = schemaParser.parse(new File("target/classes/graphql/schema.graphql"));
+
+ DataFetcher<CompletionStage<Book>> dataFetcher = environment -> {
+ CompletableFuture<Book> completableFuture = new CompletableFuture<>();
+ Book book = getBookById(environment);
+ completableFuture.complete(book);
+ return completableFuture;
+ };
+
+ RuntimeWiring runtimeWiring = RuntimeWiring.newRuntimeWiring()
+ .type("Query", builder -> builder.dataFetcher("bookById", dataFetcher))
+ .build();
+
+ SchemaGenerator schemaGenerator = new SchemaGenerator();
+ GraphQLSchema graphQLSchema = schemaGenerator.makeExecutableSchema(typeDefinitionRegistry, runtimeWiring);
+
+ GraphQL graphQL = GraphQL.newGraphQL(graphQLSchema).build();
+
+ router.route("/graphql/server").handler(GraphQLHandler.create(graphQL));
+ }
+
+ @Path("/query")
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response multipleQueries(@QueryParam("testPort") int port, @QueryParam("bookId") String bookId) {
+ JsonObject variables = new JsonObject();
+ variables.put("id", bookId);
+
+ producerTemplate.getCamelContext().getRegistry().bind("bookByIdQueryVariables", variables);
+
+ final String result = producerTemplate.requestBody(
+ "graphql://http://localhost:" + port
+ + "/graphql/server?queryFile=graphql/bookQuery.graphql&operationName=BookById&variables=#bookByIdQueryVariables",
+ null,
+ String.class);
+
+ return Response
+ .ok()
+ .entity(result)
+ .build();
+ }
+
+ private Book getBookById(DataFetchingEnvironment environment) {
+ String bookId = environment.getArgument("id");
+ return BOOKS.stream().filter(book -> book.getId().equals(bookId)).findFirst().orElse(null);
+ }
+}
diff --git a/integration-tests/graphql/src/main/java/org/apache/camel/quarkus/component/graphql/it/model/Book.java b/integration-tests/graphql/src/main/java/org/apache/camel/quarkus/component/graphql/it/model/Book.java
new file mode 100644
index 0000000..59e3430
--- /dev/null
+++ b/integration-tests/graphql/src/main/java/org/apache/camel/quarkus/component/graphql/it/model/Book.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.graphql.it.model;
+
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+public class Book {
+ private String id;
+ private String name;
+ private String authorId;
+
+ public Book(String id, String name, String authorId) {
+ this.id = id;
+ this.name = name;
+ this.authorId = authorId;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getAuthorId() {
+ return authorId;
+ }
+
+ public void setAuthorId(String authorId) {
+ this.authorId = authorId;
+ }
+}
diff --git a/integration-tests/graphql/src/main/resources/application.properties b/integration-tests/graphql/src/main/resources/application.properties
new file mode 100644
index 0000000..adb4df9
--- /dev/null
+++ b/integration-tests/graphql/src/main/resources/application.properties
@@ -0,0 +1,18 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You 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
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+quarkus.camel.graphql.query-files=classpath:graphql/bookQuery.graphql
diff --git a/integration-tests/graphql/src/main/resources/graphql/bookQuery.graphql b/integration-tests/graphql/src/main/resources/graphql/bookQuery.graphql
new file mode 100644
index 0000000..1eba989
--- /dev/null
+++ b/integration-tests/graphql/src/main/resources/graphql/bookQuery.graphql
@@ -0,0 +1,9 @@
+query BookById($id: ID) {
+ bookById(id: $id) {
+ id
+ name
+ author {
+ name
+ }
+ }
+}
diff --git a/integration-tests/graphql/src/main/resources/graphql/schema.graphql b/integration-tests/graphql/src/main/resources/graphql/schema.graphql
new file mode 100644
index 0000000..1dee4f6
--- /dev/null
+++ b/integration-tests/graphql/src/main/resources/graphql/schema.graphql
@@ -0,0 +1,28 @@
+schema {
+ query: Query,
+ mutation: Mutation
+}
+
+type Query {
+ bookById(id: ID): Book
+}
+
+type Mutation {
+ addBook(bookInput: BookInput): Book
+}
+
+type Book {
+ id: ID
+ name: String
+ author: Author
+}
+
+type Author {
+ id: ID
+ name: String
+}
+
+input BookInput {
+ name: String
+ authorId: ID
+}
diff --git a/integration-tests/graphql/src/test/java/org/apache/camel/quarkus/component/graphql/it/GraphQLIT.java b/integration-tests/graphql/src/test/java/org/apache/camel/quarkus/component/graphql/it/GraphQLIT.java
new file mode 100644
index 0000000..cf6047a
--- /dev/null
+++ b/integration-tests/graphql/src/test/java/org/apache/camel/quarkus/component/graphql/it/GraphQLIT.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.graphql.it;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+class GraphQLIT extends GraphQLTest {
+
+}
diff --git a/integration-tests/graphql/src/test/java/org/apache/camel/quarkus/component/graphql/it/GraphQLTest.java b/integration-tests/graphql/src/test/java/org/apache/camel/quarkus/component/graphql/it/GraphQLTest.java
new file mode 100644
index 0000000..869c1e2
--- /dev/null
+++ b/integration-tests/graphql/src/test/java/org/apache/camel/quarkus/component/graphql/it/GraphQLTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.graphql.it;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+class GraphQLTest {
+
+ @Test
+ public void testGraphQLComponent() {
+ RestAssured
+ .given()
+ .queryParam("testPort", RestAssured.port)
+ .queryParam("bookId", "book-1")
+ .get("/graphql/query")
+ .then()
+ .statusCode(200)
+ .body("data.bookById.name", is("Harry Potter and the Philosophers Stone"));
+ }
+}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index dc1c23b..8702a1b 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -174,6 +174,7 @@
<module>fhir</module>
<module>file</module>
<module>ftp</module>
+ <module>graphql</module>
<module>http</module>
<module>hystrix</module>
<module>infinispan</module>
diff --git a/pom.xml b/pom.xml
index 3ac391d..7c9118d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -246,6 +246,7 @@
<excludes>
<exclude>**/*.adoc</exclude>
<exclude>**/*.csv</exclude>
+ <exclude>**/*.graphql</exclude>
<exclude>**/*.ics</exclude>
<exclude>**/*.lock</exclude>
<exclude>**/*.mp3</exclude>
diff --git a/poms/bom-deployment/pom.xml b/poms/bom-deployment/pom.xml
index a2cf7cb..9531cdc 100644
--- a/poms/bom-deployment/pom.xml
+++ b/poms/bom-deployment/pom.xml
@@ -246,6 +246,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-graphql-deployment</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-gson-deployment</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>
diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml
index 52916ff..812bd8c 100644
--- a/poms/bom/pom.xml
+++ b/poms/bom/pom.xml
@@ -294,6 +294,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-graphql</artifactId>
+ <version>${camel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-gson</artifactId>
<version>${camel.version}</version>
</dependency>
@@ -887,6 +892,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-graphql</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-gson</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>