Skip to content

protoc-gen-grafbase-subgraph: fix panics when pushing packages out of order#144

Merged
tomhoule merged 1 commit into
mainfrom
tomhoule-oupyztyowuuz
Aug 1, 2025
Merged

protoc-gen-grafbase-subgraph: fix panics when pushing packages out of order#144
tomhoule merged 1 commit into
mainfrom
tomhoule-oupyztyowuuz

Conversation

@tomhoule

@tomhoule tomhoule commented Aug 1, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@tomhoule
tomhoule force-pushed the tomhoule-oupyztyowuuz branch from d8cbcda to ca6dfc0 Compare August 1, 2025 11:58
@tomhoule tomhoule changed the title protoc-gen-grafbase-subgraph: fixes protoc-gen-grafbase-subgraph: fix panics when pushing packages out of order Aug 1, 2025
@tomhoule
tomhoule marked this pull request as ready for review August 1, 2025 14:28
@tomhoule
tomhoule force-pushed the tomhoule-oupyztyowuuz branch from ca6dfc0 to 134873a Compare August 1, 2025 14:28
@tomhoule
tomhoule merged commit e3079f4 into main Aug 1, 2025
2 checks passed
@tomhoule
tomhoule deleted the tomhoule-oupyztyowuuz branch August 1, 2025 14:39
tomhoule added a commit that referenced this pull request Aug 13, 2025
### 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-9518
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants