Schema Extensions
Viaduct applications can define custom directives and common types that are shared across all modules by placing GraphQL schema files in a special directory. This provides a centralized location for schema definitions that extend Viaduct’s built-in schema components.
The schemabase directory
The Viaduct Gradle plugin automatically discovers and includes schema files from:
src/main/viaduct/schemabase/
Any .graphqls files in this directory (including subdirectories) are automatically added to your application’s schema during the build process. You do not need to manually configure or register these files.
Note: Viaduct does not yet support custom scalars.
Build integration
The assembleViaductCentralSchema Gradle task automatically:
- Scans
src/main/viaduct/schemabase/for*.graphqlsfiles - Copies them to the build output under
schemabase/ - Includes them when assembling the complete application schema
- Validates that the combined schema is valid GraphQL
You can verify the assembled schema in build/viaduct/schema/ after running:
./gradlew assembleViaductCentralSchema
Relation to Viaduct’s built-in schema
Viaduct automatically provides several built-in schema components that you don’t need to define:
- Directives:
@resolver,@scope,@idOf,@backingData - Interfaces:
Node(when used) - Scalars:
DateTime,Date,Long,BigDecimal,BigInteger,Object,Upload - Root types:
Query(always),Mutation(when extended)
For details about these built-in components, see the Developers: Schema Reference section.
Your schemabase/ files extend and complement these built-in components with application-specific definitions.
See also
- Developers: Schema Reference — Viaduct’s built-in schema components
- Developers: Resolvers — Implementing resolvers for your schema
- Getting Started: Custom Directives — Examples of using Viaduct’s built-in directives
- Service Engineers: Multiple Modules — Organizing large multi-module applications
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.