Includes
Why Includes Exist¶
As schemas grow, it is useful to split them into focused files.
For example:
Use include to bring definitions from another .vdl file into the same compilation context.
Basic Syntax¶
The included file can define types, enums, constants, or documentation used by the current file.
Example shared.vdl:
Example schema.vdl:
Session.account can use Account because schema.vdl includes shared.vdl.
Relative Paths¶
Include paths are resolved relative to the file that contains the include statement.
This makes each file self-contained: moving the entry point does not change how nested includes are resolved.
Include Graphs¶
Includes are recursive. If schema.vdl includes orders.vdl, and orders.vdl includes money.vdl, all three files are analyzed together.
Each file is processed once. Circular includes are reported as diagnostics.
File Name Rules¶
Regular included schema files should have names matching this pattern:
Good names:
Avoid names like:
Config Files Are Not Included¶
vdl.config.vdl is the project generation configuration file. It cannot be included as a normal schema file.
Keep language schemas and generation configuration separate:
Practical Advice¶
- Put shared primitives, aliases, and base objects in files like
shared.vdl. - Put event contracts in files like
events.vdloruser_events.vdl. - Keep the main entry file small and readable.
- Prefer shallow include graphs when possible.