Skip to content

Feature Request: Optional namespace grouping for SDK-style generated code #409

@lume-code

Description

@lume-code

I think it'd be a nice addition to have an optional way to group operation access methods under a namespace, so the generated code feels more like an SDK.
Something like:
<Namespace>.<OperationName>()

Taking it a step further (and this is more opinionated), it could also support grouping by a GraphQL directive. For example, the federation @join directive already points to the owning domain or backends could define their own stable grouping directive. This would give client a clean Stripe-style SDK pattern:
<Namespace>.<GroupedByDirective>.<OperationName>()

There are some edge cases to handle:

  • Operations with multiple/different directives (maybe move them to a common namespace with a warning?)
  • Case style conversions

I've actually taken this approach by writing our own SDK generator for a federated API with 300+ operations. It worked well and clean enough that we didn't need another layer on top for shipping as an SDK.
The other nice thing would be: when a document has a single operation, comments can pass directly to the generated method, which keeps docs intact.

Thought maybe share it here if there is an interest from maintainer to allow these internally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions