wgc 0.80.0 → 0.81.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wgc",
3
- "version": "0.80.0",
3
+ "version": "0.81.0",
4
4
  "description": "The official CLI tool to manage the GraphQL Federation Platform Cosmo",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -99,5 +99,5 @@
99
99
  "typescript": "5.5.2",
100
100
  "vitest": "^3.1.2"
101
101
  },
102
- "gitHead": "84818397f9745a4d7a5923a02d41d25bad5ea727"
102
+ "gitHead": "299832521162f51632168e8c690d35800157c9de"
103
103
  }
@@ -1,5 +0,0 @@
1
- export declare const goMod = "\nmodule {modulePath}\n\ngo 1.24.1\n\nrequire (\n github.com/stretchr/testify v1.10.0\n github.com/wundergraph/cosmo/router-plugin v0.0.0-20250519132817-0768029ce9e5\n google.golang.org/grpc v1.68.1\n google.golang.org/protobuf v1.36.5\n)\n";
2
- export declare const mainGo = "package main\n\nimport (\n \"context\"\n \"log\"\n \"strconv\"\n\n service \"github.com/wundergraph/cosmo/plugin/generated\"\n\n routerplugin \"github.com/wundergraph/cosmo/router-plugin\"\n \"google.golang.org/grpc\"\n)\n\nfunc main() {\n pl, err := routerplugin.NewRouterPlugin(func(s *grpc.Server) {\n s.RegisterService(&service.{serviceName}_ServiceDesc, &{serviceName}{\n nextID: 1,\n })\n })\n\n if err != nil {\n log.Fatalf(\"failed to create router plugin: %v\", err)\n }\n\n pl.Serve()\n}\n\ntype {serviceName} struct {\n service.Unimplemented{serviceName}Server\n nextID int\n}\n\nfunc (s *{serviceName}) QueryHello(ctx context.Context, req *service.QueryHelloRequest) (*service.QueryHelloResponse, error) {\n response := &service.QueryHelloResponse{\n Hello: &service.World{\n Id: strconv.Itoa(s.nextID),\n Name: req.Name,\n },\n }\n s.nextID++\n return response, nil\n}\n";
3
- export declare const mainGoTest = "package main\n\nimport (\n \"context\"\n \"net\"\n \"testing\"\n\n \"github.com/stretchr/testify/assert\"\n \"github.com/stretchr/testify/require\"\n service \"github.com/wundergraph/cosmo/plugin/generated\"\n \"google.golang.org/grpc\"\n \"google.golang.org/grpc/credentials/insecure\"\n \"google.golang.org/grpc/test/bufconn\"\n)\n\nconst bufSize = 1024 * 1024\n\n// testService is a wrapper that holds the gRPC test components\ntype testService struct {\n grpcConn *grpc.ClientConn\n client service.{serviceName}Client\n cleanup func()\n}\n\n// setupTestService creates a local gRPC server for testing\nfunc setupTestService(t *testing.T) *testService {\n // Create a buffer for gRPC connections\n lis := bufconn.Listen(bufSize)\n\n // Create a new gRPC server\n grpcServer := grpc.NewServer()\n\n // Register our service\n service.Register{serviceName}Server(grpcServer, &{serviceName}{\n nextID: 1,\n })\n\n // Start the server\n go func() {\n if err := grpcServer.Serve(lis); err != nil {\n t.Fatalf(\"failed to serve: %v\", err)\n }\n }()\n\n // Create a client connection\n dialer := func(context.Context, string) (net.Conn, error) {\n return lis.Dial()\n }\n conn, err := grpc.Dial(\n \"passthrough:///bufnet\",\n grpc.WithContextDialer(dialer),\n grpc.WithTransportCredentials(insecure.NewCredentials()),\n )\n require.NoError(t, err)\n\n // Create the service client\n client := service.New{serviceName}Client(conn)\n\n // Return cleanup function\n cleanup := func() {\n conn.Close()\n grpcServer.Stop()\n }\n\n return &testService{\n grpcConn: conn,\n client: client,\n cleanup: cleanup,\n }\n}\n\nfunc TestQueryHello(t *testing.T) {\n // Set up basic service\n svc := setupTestService(t)\n defer svc.cleanup()\n\n tests := []struct {\n name string\n userName string\n wantId string\n wantName string\n wantErr bool\n }{\n {\n name: \"valid hello\",\n userName: \"Alice\",\n wantId: \"1\",\n wantName: \"Alice\",\n wantErr: false,\n },\n {\n name: \"empty name\",\n userName: \"\",\n wantId: \"2\",\n wantName: \"\", // Empty name should be preserved\n wantErr: false,\n },\n {\n name: \"special characters\",\n userName: \"John & Jane\",\n wantId: \"3\",\n wantName: \"John & Jane\",\n wantErr: false,\n },\n }\n\n for _, tt := range tests {\n t.Run(tt.name, func(t *testing.T) {\n req := &service.QueryHelloRequest{\n Name: tt.userName,\n }\n\n resp, err := svc.client.QueryHello(context.Background(), req)\n if tt.wantErr {\n assert.Error(t, err)\n return\n }\n\n assert.NoError(t, err)\n assert.NotNil(t, resp.Hello)\n assert.Equal(t, tt.wantId, resp.Hello.Id)\n assert.Equal(t, tt.wantName, resp.Hello.Name)\n })\n }\n}\n\nfunc TestSequentialIDs(t *testing.T) {\n // Set up basic service\n svc := setupTestService(t)\n defer svc.cleanup()\n\n // The first request should get ID \"1\"\n firstReq := &service.QueryHelloRequest{Name: \"First\"}\n firstResp, err := svc.client.QueryHello(context.Background(), firstReq)\n require.NoError(t, err)\n assert.Equal(t, \"1\", firstResp.Hello.Id)\n\n // The second request should get ID \"2\"\n secondReq := &service.QueryHelloRequest{Name: \"Second\"}\n secondResp, err := svc.client.QueryHello(context.Background(), secondReq)\n require.NoError(t, err)\n assert.Equal(t, \"2\", secondResp.Hello.Id)\n\n // The third request should get ID \"3\"\n thirdReq := &service.QueryHelloRequest{Name: \"Third\"}\n thirdResp, err := svc.client.QueryHello(context.Background(), thirdReq)\n require.NoError(t, err)\n assert.Equal(t, \"3\", thirdResp.Hello.Id)\n}\n";
4
- export declare const readme = "# {name} Plugin - Cosmo gRPC Subgraph Example\n\nThis repository contains a simple Cosmo gRPC subgraph plugin that showcases how to design APIs with GraphQL but implement them using gRPC methods instead of traditional resolvers.\n\n## What is this demo about?\n\nThis demo illustrates a key pattern in Cosmo subgraph development:\n- **Design with GraphQL**: Define your API using GraphQL schema\n- **Implement with gRPC**: Instead of writing GraphQL resolvers, implement gRPC service methods\n- **Bridge the gap**: The Cosmo router connects GraphQL operations to your gRPC implementations\n- **Test-Driven Development**: Test your gRPC service implementation with gRPC client and server without external dependencies\n\nThe plugin demonstrates:\n- How GraphQL types and operations map to gRPC service methods\n- Simple \"Hello World\" implementation\n- Proper structure for a Cosmo gRPC subgraph plugin\n- How to test your gRPC service implementation with gRPC client and server without external dependencies\n\n## Plugin Structure\n\n- `src/` - Contains the plugin source code\n - `main.go` - The gRPC service implementation with methods that replace GraphQL resolvers\n - `main_test.go` - The gRPC service implementation with methods that replace GraphQL resolvers\n - `schema.graphql` - The GraphQL schema defining the API contract\n- `generated/` - Contains generated code from the plugin schema\n- `bin/` - Contains compiled binaries of the plugin\n\n## GraphQL to gRPC Mapping\n\nThe plugin shows how GraphQL operations map to gRPC methods:\n\n| GraphQL Operation | gRPC Method |\n|-------------------|-------------|\n| `query { hello }` | `QueryHello()` |\n\n## GraphQL Schema\n\n```graphql\ntype World {\n id: ID!\n name: String!\n}\n\ntype Query {\n hello(name: String!): World!\n}\n```\n\n## Getting Started\n\n1. **Build the plugin**\n\n ```\n wgc router plugin build <plugin-directory>\n ```\n\n2. **Compose your supergraph with your gRPC subgraph**\n\n config.yaml\n ```yaml\n subgraphs:\n - name: <plugin-name>\n plugin:\n version: 0.0.1\n directory: <plugin-directory>/<plugin-name>\n ```\n\n3. **Build the federated graph**\n\n ```bash\n wgc router compose config.yaml\n ```\n\n4. **Test the plugin**\n\n ```bash\n wgc router plugin test <plugin-directory>/<plugin-name>\n ```\n or\n ```bash\n go test src -v\n ```\n if you have the Go toolchain already installed.\n\n5. **Start the router**\n\n ```yaml\n execution_config:\n file:\n path: ./config.yaml\n plugins:\n - <plugin-directory>\n ```\n\n6. **Query the hello endpoint**\n\n Once running, you can perform GraphQL operations like:\n \n ```graphql\n # Hello query\n query {\n hello(name: \"World\") {\n id\n name\n }\n }\n ```\n\n## Further Steps\n\n- Change the plugin code in `src/main.go` and rebuild the plugin\n- Change the GraphQL schema in `src/schema.graphql` and rebuild the plugin\n\n## Learn More\n\nFor more information about Cosmo and building subgraph plugins, visit the [Cosmo documentation](https://cosmo-docs.wundergraph.com).";
5
- export declare const schema = "type World {\n \"\"\"\n The ID of the world\n \"\"\"\n id: ID!\n \"\"\"\n The name of the world\n \"\"\"\n name: String!\n}\n\ntype Query {\n \"\"\"\n The hello query\n \"\"\"\n hello(name: String!): World!\n}\n";
@@ -1 +0,0 @@
1
- {"version":3,"file":"go-plugin.js","sourceRoot":"","sources":["../../../../../../src/commands/router/plugin/templates/go-plugin.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,+CAA+C;AAE/C,MAAM,CAAC,MAAM,KAAK,GAAG;;;;;;;;;;;CAWpB,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CrB,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqJzB,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qIAmH+G,CAAC;AAEtI,MAAM,CAAC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;CAiBrB,CAAC"}