Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
d07f2d4
feat(protographic): add GraphQL to Proto type mapper
asoorm Oct 24, 2025
a2a2163
feat(protographic): add field number manager
asoorm Oct 24, 2025
e92615b
feat(protographic): add request message builder
asoorm Oct 24, 2025
a28bc63
feat(protographic): add proto text generator
asoorm Oct 24, 2025
5db9dd0
feat(protographic): integrate operation-to-proto modules
asoorm Oct 24, 2025
e2c8fbe
feat(protographic): add request message builder
asoorm Oct 24, 2025
32c28c5
fix(protographic): use Kind.SELECTION_SET enum instead of string literal
asoorm Oct 24, 2025
83138ee
feat(protographic): implement GraphQL fragment denormalization for op…
asoorm Oct 24, 2025
3fbbf11
feat: add opt-in queryNoSideEffects option for Query operations
asoorm Oct 24, 2025
aa2e5fe
Nested messages now follow protobuf best practices with PascalCase na…
asoorm Oct 24, 2025
c318ace
we don't need prefixes for RPC methods
asoorm Oct 24, 2025
9c25603
fixing imports for protobuf
asoorm Oct 24, 2025
c5e45fe
implemented field ordering stability for operations-to-proto utilisin…
asoorm Oct 24, 2025
31a86e0
Based on the diff, here's a commit message:
asoorm Oct 24, 2025
0b87d4e
supporting streaming
asoorm Oct 24, 2025
c77d79d
changed from verbose naming to simle naming
asoorm Oct 25, 2025
6e99d3c
enum support
asoorm Oct 25, 2025
f1cf11b
prettier
asoorm Oct 25, 2025
edacf7f
ingle-line if statements without curly braces violated ESLint's curly…
asoorm Oct 25, 2025
d4f6b6c
the service name needs to be exactly the name provided - we shouldn't…
asoorm Oct 25, 2025
4ac2bcd
feat(cli): add multi-language proto options for gRPC generation
asoorm Oct 25, 2025
7ed74cf
linting
asoorm Oct 25, 2025
256efaa
improving DX of query idempotency
asoorm Oct 25, 2025
30960dc
support for custom scalar mappings
asoorm Oct 25, 2025
66f2dc2
include gqls and graphqls files
asoorm Oct 25, 2025
bb2d6cf
repace bad regex assertions with inline snapshot approach
asoorm Oct 25, 2025
7ef3121
removing misleading comment / artifact
asoorm Oct 25, 2025
3469b74
return an error, don't silently ignore unknown fields
asoorm Oct 25, 2025
e92cbdb
feat(protographic): add proto reversibility validations
asoorm Oct 25, 2025
a2746c4
Tests for Nested Interface and Union Field Resolvers
asoorm Oct 25, 2025
0a9d083
refactor(tests): replace brute-force path resolution with validation-…
asoorm Oct 25, 2025
65679c1
refactor(protographic): use dot notation for nested proto message pat…
asoorm Oct 25, 2025
be1f2cc
added tests for neste input objects - in object field ordering
asoorm Oct 25, 2025
71b27fc
inline snapshot for enum tests
asoorm Oct 25, 2025
40181ed
prefer inline snapshots for tests
asoorm Oct 25, 2025
4c60e2d
replaced runtime type check with GQL type guards.
asoorm Oct 25, 2025
0241a56
use SelectionNode instead of any
asoorm Oct 25, 2025
e68dfc5
linting
asoorm Oct 25, 2025
ff13565
fixing use of any
asoorm Oct 25, 2025
d6c47d9
removing the last any
asoorm Oct 25, 2025
97ad507
type safety
asoorm Oct 25, 2025
f880665
feat(protographic): add GraphQL validation and recursion protection
asoorm Oct 26, 2025
3758713
linting
asoorm Oct 26, 2025
35ef84d
fix(protographic): support nested lists in operations-to-proto
asoorm Oct 28, 2025
9c25e37
disable untested languages
asoorm Oct 28, 2025
ea1670c
field stability tests - inline snapshot
asoorm Oct 28, 2025
5cff6f4
feat(cli): add --prefix-operation-type flag to grpc-service generate
asoorm Nov 7, 2025
d57fc74
feat(grpc-service): add prefix-operation-type flag
asoorm Nov 7, 2025
70f934d
docs(protographic): separate alpha operations-to-proto docs
asoorm Nov 7, 2025
e37311f
WIP
asoorm Nov 9, 2025
38b2c4b
linting
asoorm Nov 12, 2025
a294dfb
fix(cli): convert undefined to null for lockData type compatibility
asoorm Nov 12, 2025
1d46577
fixing the documentation to remove capabilities we are not exposing i…
asoorm Nov 13, 2025
094e87d
Merge branch 'main' into ahmet/eng-8163-operations-to-proto
asoorm Nov 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
567 changes: 537 additions & 30 deletions cli/src/commands/grpc-service/commands/generate.ts

Large diffs are not rendered by default.

664 changes: 664 additions & 0 deletions protographic/OPERATIONS_TO_PROTO.md

Large diffs are not rendered by default.

37 changes: 34 additions & 3 deletions protographic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ A tool for converting GraphQL Schema Definition Language (SDL) to Protocol Buffe

## Overview

Protographic bridges GraphQL and Protocol Buffers (protobuf) ecosystems through two core functions:
Protographic bridges GraphQL and Protocol Buffers (protobuf) ecosystems through three core functions:

1. **GraphQL SDL to Protocol Buffer (Proto) Compiler**: Transforms GraphQL schemas into Proto3 format, allowing developers to write gRPC services using GraphQL SDL and integrate them seamlessly into the Cosmo Router as standard subgraphs. This is used at build-time.

2. **GraphQL SDL to Mapping Compiler**: Creates mapping definitions that maintain the semantic relationships between GraphQL types while adapting them to Protocol Buffer's structural model. This is used by the Cosmo Router at runtime.
2. **GraphQL Operations to Protocol Buffer Compiler** ⚠️ **ALPHA**: Converts GraphQL operations (queries, mutations, subscriptions) into Proto3 service definitions with corresponding request/response messages. This enables operation-first development where you define your API through GraphQL operations rather than schema types.

3. **GraphQL SDL to Mapping Compiler**: Creates mapping definitions that maintain the semantic relationships between GraphQL types while adapting them to Protocol Buffer's structural model. This is used by the Cosmo Router at runtime.

## Key Features

- Precise conversion of GraphQL types to Protocol Buffer messages
- **Operations-to-Proto** (alpha): Generate proto services directly from GraphQL operations
- Consistent naming conventions across GraphQL and Proto definitions
- Streamlined mapping of GraphQL operations to RPC methods
- Robust handling of complex GraphQL features (unions, interfaces, directives)
- Handles GraphQL features including unions, interfaces, directives, and fragments
- First-class support for Federation entity mapping
- Deterministic field ordering with proto.lock.json for backward compatibility
- Use of Protocol Buffer wrappers for nullable fields to distinguish between semantic nulls and zero values
Expand Down Expand Up @@ -114,6 +117,34 @@ The lock data records the order of:

New fields are always added at the end, maintaining backward compatibility with existing proto messages.

### Converting GraphQL Operations to Protocol Buffer ⚠️ ALPHA

> **Note**: This feature is currently in alpha. The API may change in future releases.

Protographic can generate proto services directly from GraphQL operations, enabling an operation-first development approach. For detailed documentation, see [OPERATIONS_TO_PROTO.md](OPERATIONS_TO_PROTO.md).

Quick example:

```typescript
import { compileOperationsToProto } from '@wundergraph/protographic';

const operation = `
query GetUser($userId: ID!) {
user(id: $userId) {
id
name
email
}
}
`;

const result = compileOperationsToProto(operation, schema, {
serviceName: 'UserService',
packageName: 'user.v1',
prefixOperationType: true
});
```

### Generating Mapping Definitions

```typescript
Expand Down
36 changes: 36 additions & 0 deletions protographic/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,42 @@ export { GraphQLToProtoTextVisitor } from './sdl-to-proto-visitor.js';
export { ProtoLockManager } from './proto-lock.js';
export { SDLValidationVisitor } from './sdl-validation-visitor.js';

// Export operation-to-proto functionality
export { compileOperationsToProto } from './operation-to-proto.js';
export type { OperationsToProtoOptions, CompileOperationsToProtoResult } from './operation-to-proto.js';

// Export operation modules
export {
mapGraphQLTypeToProto,
getProtoTypeName,
isGraphQLScalarType,
requiresWrapperType,
getRequiredImports,
} from './operations/type-mapper.js';
export type { ProtoTypeInfo, TypeMapperOptions } from './operations/type-mapper.js';

export { createFieldNumberManager } from './operations/field-numbering.js';
export type { FieldNumberManager } from './operations/field-numbering.js';

export {
buildMessageFromSelectionSet,
buildFieldDefinition,
buildNestedMessage,
} from './operations/message-builder.js';
export type { MessageBuilderOptions } from './operations/message-builder.js';

export { buildRequestMessage, buildInputObjectMessage, buildEnumType } from './operations/request-builder.js';
export type { RequestBuilderOptions } from './operations/request-builder.js';

export {
rootToProtoText,
serviceToProtoText,
messageToProtoText,
enumToProtoText,
formatField,
} from './operations/proto-text-generator.js';
export type { ProtoTextOptions } from './operations/proto-text-generator.js';

export type { GraphQLToProtoTextVisitorOptions } from './sdl-to-proto-visitor.js';
export type { ProtoLock } from './proto-lock.js';
export type { ValidationResult } from './sdl-validation-visitor.js';
Expand Down
Loading
Loading