Commit 037de4f
committed
protoc-gen-grafbase-subgraph: release 0.3.0
### Added
- **Multiple subgraphs support** added. Support for generating multiple GraphQL files based on service annotations:
- Services can now have a `subgraph_name` option that maps them to different subgraph files
- When any service has a `subgraph_name`, the tool automatically switches to multi-file mode
- Generated files are named `<subgraph_name>.graphql` instead of the default `schema.graphql`
- Each subgraph file only includes the services and types relevant to that specific subgraph
- Multiple services can map to the same subgraph
- Services without `subgraph_name` in multi-file mode are ignored without warning
- **Proto3 optional field support** added. The generator now properly handles proto3 optional fields:
- Non-optional scalar and enum fields in proto3 are rendered as non-nullable (`Type!`) in GraphQL output types
- Optional scalar and enum fields are rendered as nullable (`Type`) in GraphQL output types
- Message type fields are always nullable regardless of the optional flag
- Input types remain nullable for all fields
- The generator now declares support for `FEATURE_PROTO3_OPTIONAL` to work with proto3 files containing optional fields
- **Composite schemas shortcuts** added. New protobuf options for simplified composite schemas directives:
- `grafbase.graphql.key` option generates `@key` directives on types
- `grafbase.graphql.lookup` option generates `@lookup` directive on RPC methods
- `grafbase.graphql.argument_is` option on RPC methods generates `@is` directive on the input argument - a shortcut for `grafbase.graphql.argument_directives = "@is(field: \"...\")"`
- `grafbase.graphql.join_field` option generates fields with `@require` and `@grpcMethod` directives, with proper type resolution
- **Input argument directives** added. You can now add GraphQL directives to RPC method input argument, that corresponds to the input of the RPC method, using the `grafbase.graphql.argument_directives` option on methods.
- **Composite schema entity references with @derive** added. You can now create federation-style entity references using the `grafbase.graphql.derive_field` option on messages:
- Use `option (grafbase.graphql.derive_field) = {entity: "User", is: "{ id: user_id }"};` on fields
- Automatically generates reference fields with `@derive` and `@is` directives
- Creates stub entity types with `@key` directives if the type is not already defined
- Supports custom relation field names with the `name` parameter
- The `@is` directive uses the value from the `is` parameter directly
- Enables cross-subgraph entity references in federated schemas
- **Input argument directives support** added. You can now add GraphQL directives to RPC method input arguments using the `grafbase.graphql.argument_directives` option:
- Use `option (grafbase.graphql.argument_directives) = "@constraint(minLength: 1)";` in method options
- Supports multiple directives in a single string, separated by spaces
- Works with both Query and Mutation fields
- Can be combined with existing method directives
### Fixed
- In some scenarios, the plugin would panic because packages were not provided in alphabetical order. This is fixed. (#144)
closes GB-95181 parent 810cb24 commit 037de4f
3 files changed
Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
| 5 | + | |
10 | 6 | | |
11 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
20 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
21 | 31 | | |
22 | 32 | | |
23 | 33 | | |
24 | 34 | | |
25 | 35 | | |
26 | 36 | | |
27 | 37 | | |
28 | | - | |
| 38 | + | |
29 | 39 | | |
30 | 40 | | |
31 | 41 | | |
32 | 42 | | |
33 | 43 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
0 commit comments