Installation
This guide walks you through setting up Viaduct in a new or existing Gradle project. You’ll configure the Viaduct Gradle plugins, add the necessary dependencies, and set up the project structure for developing Viaduct tenant modules.Prerequisites
- Java JDK 21 or higher
- Gradle 8.10+ (Gradle 9.1.0+ supported with Kotlin 2.0+)
- Kotlin 1.9.x or 2.x (depending on your Gradle version)
Refer to the Gradle-Kotlin compatibility matrix to choose compatible versions for your project.
Create a new project
If you’re starting from scratch, create a new directory for your project:Configure Gradle
Create settings.gradle.kts
Create a This configuration:
settings.gradle.kts file to configure plugin management and dependency resolution:settings.gradle.kts
- Sets up Maven Central and Gradle Plugin Portal as plugin repositories
- Configures dependency resolution to use Maven Central
- Creates a version catalog from a TOML file for managing dependencies
Create version catalog
Create a
gradle/viaduct.versions.toml file to manage dependency versions:gradle/viaduct.versions.toml
Make sure to check Maven Central for the latest Viaduct version.
Create build.gradle.kts
Create a
build.gradle.kts file with the Viaduct plugins and dependencies:build.gradle.kts
Set up project structure
Viaduct applications follow a specific directory structure:Create schema directory
Create the directory structure for your GraphQL schema:All
*.graphqls files in this directory will be included in your schema.Create Kotlin source directories
Create directories for your application code and resolvers:The package structure should match the
modulePackagePrefix configured in your build.gradle.kts.Understanding Viaduct dependencies
Viaduct provides several artifacts for different use cases:Core dependencies
- viaduct-api: Contains the core API definitions, annotations (
@Resolver), and interfaces you’ll use in your code - viaduct-runtime: Provides the runtime implementation of the Viaduct engine
- viaduct-bom: Bill of Materials for managing dependency versions (optional but recommended)
- viaduct-test-fixtures: Testing utilities for writing resolver tests (test dependency only)
Engine and service dependencies
For advanced use cases or if you’re building custom Viaduct integrations, you may need additional dependencies:Configure plugin behavior
The Viaduct plugins can be customized through DSL blocks:Application plugin configuration
build.gradle.kts
modulePackagePrefix tells Viaduct where to find your resolver classes. This should match your actual package structure.
Module plugin configuration
build.gradle.kts
modulePackageSuffix defines where resolvers are located within the module. The full package path for resolvers will be {modulePackagePrefix}.{modulePackageSuffix}.
Multi-module projects
For larger applications, you can structure your project as a multi-module Gradle build:- Apply
viaduct.applicationplugin to the root or main application project - Apply
viaduct.moduleplugin to each module that contains resolvers - Each module can have its own
src/main/viaduct/schema/directory - Modules can depend on each other and share GRTs
The Star Wars demo app is a great example of a multi-module Viaduct application.
Verify installation
Verify that your Viaduct installation is working:Build the project
Run the Gradle build:The build should complete successfully, even if you haven’t added any schema or resolvers yet.
Next steps
Now that you have Viaduct installed, you can:Define your schema
Create GraphQL schemas with types and resolvers
Write resolvers
Implement business logic with resolver classes
Run the dev server
Start the development server with GraphiQL
Explore examples
Check out the demo applications for inspiration
Troubleshooting
Plugin not found error
Plugin not found error
If you see an error like “Plugin [id: ‘com.airbnb.viaduct.application-gradle-plugin’] was not found”:
- Verify that Maven Central and Gradle Plugin Portal are configured in
pluginManagement - Check that the Viaduct version in
gradle/viaduct.versions.tomlis valid - Try running with
--refresh-dependenciesflag:./gradlew build --refresh-dependencies
Code generation fails
Code generation fails
If code generation fails during the build:
- Ensure both
viaduct.applicationandviaduct.moduleplugins are applied - Verify that
modulePackagePrefixmatches your actual package structure - Check that your schema files are in
src/main/viaduct/schema/and have.graphqlsextension - Run with
--stacktraceto see detailed error messages:./gradlew build --stacktrace
Incompatible Gradle/Kotlin versions
Incompatible Gradle/Kotlin versions
If you see version compatibility errors:
- Check the Gradle-Kotlin compatibility matrix
- Update your Kotlin version in
gradle/viaduct.versions.toml - Ensure your Gradle wrapper version is compatible:
./gradlew wrapper --gradle-version 8.14
Dependency resolution fails
Dependency resolution fails
If dependencies can’t be resolved:
- Verify that
mavenCentral()is configured in bothpluginManagementanddependencyResolutionManagement - Try clearing the Gradle cache:
rm -rf ~/.gradle/caches/ - Run with
--refresh-dependencies:./gradlew build --refresh-dependencies