Skip to content

Conversation

@tomhoule
Copy link
Collaborator

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

closes GB-9518

### 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
@tomhoule tomhoule merged commit 6395f28 into main Aug 13, 2025
2 checks passed
@tomhoule tomhoule deleted the tomhoule-okmzoqtuwrsz branch August 13, 2025 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants