Skip to content
Closed

init #2617

Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions cli/src/commands/router/commands/plugin/templates/go.ts

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions cli/src/commands/router/commands/plugin/templates/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
// This file is auto-generated. Do not edit manually.
/* eslint-disable no-template-curly-in-string */

const gitignore = '# Ignore the binary files\nbin/\n';
const gitignore = '# Ignore the binary files\r\nbin/\r\n';

const makefile =
'\n.PHONY: build test generate install-wgc\n\ninstall-wgc:\n\t@which wgc > /dev/null 2>&1 || npm install -g wgc@latest\n\nmake: build\n\ntest: install-wgc\n\twgc router plugin test .\n\ngenerate: install-wgc\n\twgc router plugin generate .\n\npublish: generate\n\twgc router plugin publish .\n\nbuild: install-wgc\n\twgc router plugin build . --debug\n';
'\r\n.PHONY: build test generate install-wgc\r\n\r\ninstall-wgc:\r\n\t@which wgc > /dev/null 2>&1 || npm install -g wgc@latest\r\n\r\nmake: build\r\n\r\ntest: install-wgc\r\n\twgc router plugin test .\r\n\r\ngenerate: install-wgc\r\n\twgc router plugin generate .\r\n\r\npublish: generate\r\n\twgc router plugin publish .\r\n\r\nbuild: install-wgc\r\n\twgc router plugin build . --debug\r\n';

const readmePluginMd =
'# {name} Plugin - Cosmo gRPC Service Example\n\nThis repository contains a simple Cosmo gRPC service plugin that showcases how to design APIs with GraphQL Federation 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 gRPC service 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 service plugin\n- How to test your gRPC service implementation with gRPC client and server without external dependencies\n\n{readmeText}\n\n## 🔧 Customizing Your Plugin\n\n- Change the GraphQL schema in `src/schema.graphql` and regenerate the code with `make generate`.\n- Implement the changes in `src/{mainFile}` and test your implementation with `make test`.\n- Build the plugin with `make build`.\n\n## 📚 Learn More\n\nFor more information about Cosmo and building router plugins:\n- [Cosmo Documentation](https://cosmo-docs.wundergraph.com/)\n- [Cosmo Router Plugins Guide](https://cosmo-docs.wundergraph.com/connect/plugins)\n\n---\n\n<p align="center">Made with ❤️ by <a href="https://wundergraph.com">WunderGraph</a></p>';
'# {name} Plugin - Cosmo gRPC Service Example\r\n\r\nThis repository contains a simple Cosmo gRPC service plugin that showcases how to design APIs with GraphQL Federation but implement them using gRPC methods instead of traditional resolvers.\r\n\r\n## What is this demo about?\r\n\r\nThis demo illustrates a key pattern in Cosmo gRPC service development:\r\n- **Design with GraphQL**: Define your API using GraphQL schema\r\n- **Implement with gRPC**: Instead of writing GraphQL resolvers, implement gRPC service methods\r\n- **Bridge the gap**: The Cosmo router connects GraphQL operations to your gRPC implementations\r\n- **Test-Driven Development**: Test your gRPC service implementation with gRPC client and server without external dependencies\r\n\r\nThe plugin demonstrates:\r\n- How GraphQL types and operations map to gRPC service methods\r\n- Simple "Hello World" implementation\r\n- Proper structure for a Cosmo gRPC service plugin\r\n- How to test your gRPC service implementation with gRPC client and server without external dependencies\r\n\r\n{readmeText}\r\n\r\n## 🔧 Customizing Your Plugin\r\n\r\n- Change the GraphQL schema in `src/schema.graphql` and regenerate the code with `make generate`.\r\n- Implement the changes in `src/{mainFile}` and test your implementation with `make test`.\r\n- Build the plugin with `make build`.\r\n\r\n## 📚 Learn More\r\n\r\nFor more information about Cosmo and building router plugins:\r\n- [Cosmo Documentation](https://cosmo-docs.wundergraph.com/)\r\n- [Cosmo Router Plugins Guide](https://cosmo-docs.wundergraph.com/connect/plugins)\r\n\r\n---\r\n\r\n<p align="center">Made with ❤️ by <a href="https://wundergraph.com">WunderGraph</a></p>';

const cursorignore =
'# Ignore the mapping and lock files\ngenerated/mapping.json\ngenerated/service.proto.lock.json\n# Ignore the proto to avoid interpretation issues\ngenerated/service.proto\n# Ignore the plugin binary\nbin/\n';
'# Ignore the mapping and lock files\r\ngenerated/mapping.json\r\ngenerated/service.proto.lock.json\r\n# Ignore the proto to avoid interpretation issues\r\ngenerated/service.proto\r\n# Ignore the plugin binary\r\nbin/\r\n';

const schemaGraphql =
'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';
'type World {\r\n """\r\n The ID of the world\r\n """\r\n id: ID!\r\n """\r\n The name of the world\r\n """\r\n name: String!\r\n}\r\n\r\ntype Query {\r\n """\r\n The hello query\r\n """\r\n hello(name: String!): World!\r\n}\r\n';

export default {
gitignore,
Expand Down
12 changes: 6 additions & 6 deletions cli/src/commands/router/commands/plugin/templates/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
// This file is auto-generated. Do not edit manually.
/* eslint-disable no-template-curly-in-string */

const gitignore = '# Ignore the binary files\nrelease/\n';
const gitignore = '# Ignore the binary files\r\nrelease/\r\n';

const makefile =
'\n.PHONY: install-wgc build download start compose\n\nmake: install-wgc download build compose start\n\ninstall-wgc:\n\t@which wgc > /dev/null 2>&1 || npm install -g wgc@latest\n\nstart:\n\t./release/router\n\ncompose: install-wgc\n\twgc router compose -i graph.yaml -o config.json\n\ndownload: install-wgc\n\t@if [ ! -f release/router ]; then \\\n\t\trm -rf release && wgc router download-binary -o release && chmod +x release/router; \\\n\telse \\\n\t\techo "Router binary already exists, skipping download"; \\\n\tfi\n\nbuild:\n\tcd plugins/{originalPluginName} && make build\n';
'\r\n.PHONY: install-wgc build download start compose\r\n\r\nmake: install-wgc download build compose start\r\n\r\ninstall-wgc:\r\n\t@which wgc > /dev/null 2>&1 || npm install -g wgc@latest\r\n\r\nstart:\r\n\t./release/router\r\n\r\ncompose: install-wgc\r\n\twgc router compose -i graph.yaml -o config.json\r\n\r\ndownload: install-wgc\r\n\t@if [ ! -f release/router ]; then \\\r\n\t\trm -rf release && wgc router download-binary -o release && chmod +x release/router; \\\r\n\telse \\\r\n\t\techo "Router binary already exists, skipping download"; \\\r\n\tfi\r\n\r\nbuild:\r\n\tcd plugins/{originalPluginName} && make build\r\n';

const readmePluginMd =
'# {name} Plugin - Cosmo Router Example\n\nThis repository contains a simple Cosmo Router plugin that showcases how to design APIs with GraphQL Federation 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 Router plugin 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 RPC methods\n- Simple "Hello World" implementation\n- Proper structure for a Cosmo Router plugin\n- How to test your gRPC implementation with gRPC client and server without external dependencies\n\n{readmeText}\n\n## 🔧 Customizing Your Plugin\n\n- Change the GraphQL schema in `src/schema.graphql` and regenerate the code with `make generate`.\n- Implement the changes in `src/{mainFile}` and test your implementation with `make test`.\n- Compose your supergraph with `make compose` and restart the router with `make start`.\n\n## 📚 Learn More\n\nFor more information about Cosmo and building router plugins:\n- [Cosmo Documentation](https://cosmo-docs.wundergraph.com/)\n- [Cosmo Router Plugins Guide](https://cosmo-docs.wundergraph.com/connect/plugins)\n\n---\n\n<p align="center">Made with ❤️ by <a href="https://wundergraph.com">WunderGraph</a></p>';
'# {name} Plugin - Cosmo Router Example\r\n\r\nThis repository contains a simple Cosmo Router plugin that showcases how to design APIs with GraphQL Federation but implement them using gRPC methods instead of traditional resolvers.\r\n\r\n## What is this demo about?\r\n\r\nThis demo illustrates a key pattern in Cosmo Router plugin development:\r\n- **Design with GraphQL**: Define your API using GraphQL schema\r\n- **Implement with gRPC**: Instead of writing GraphQL resolvers, implement gRPC service methods\r\n- **Bridge the gap**: The Cosmo router connects GraphQL operations to your gRPC implementations\r\n- **Test-Driven Development**: Test your gRPC service implementation with gRPC client and server without external dependencies\r\n\r\nThe plugin demonstrates:\r\n- How GraphQL types and operations map to gRPC RPC methods\r\n- Simple "Hello World" implementation\r\n- Proper structure for a Cosmo Router plugin\r\n- How to test your gRPC implementation with gRPC client and server without external dependencies\r\n\r\n{readmeText}\r\n\r\n## 🔧 Customizing Your Plugin\r\n\r\n- Change the GraphQL schema in `src/schema.graphql` and regenerate the code with `make generate`.\r\n- Implement the changes in `src/{mainFile}` and test your implementation with `make test`.\r\n- Compose your supergraph with `make compose` and restart the router with `make start`.\r\n\r\n## 📚 Learn More\r\n\r\nFor more information about Cosmo and building router plugins:\r\n- [Cosmo Documentation](https://cosmo-docs.wundergraph.com/)\r\n- [Cosmo Router Plugins Guide](https://cosmo-docs.wundergraph.com/connect/plugins)\r\n\r\n---\r\n\r\n<p align="center">Made with ❤️ by <a href="https://wundergraph.com">WunderGraph</a></p>';

const readmeProjectMd =
'# {name} - Cosmo Router Plugin Project\n\nDesign your API with GraphQL Federation and implement with gRPC using Cosmo Router Plugins\n\n## ✨ Features\n\n- **GraphQL Schema + gRPC Implementation**: Design your API with GraphQL SDL and implement it using gRPC methods\n- **Embedded Subgraphs**: Run subgraphs directly inside the Cosmo Router for improved performance\n- **End-to-End Type Safety**: Auto-generated Go code from your GraphQL schema\n- **Simplified Testing**: Unit test your gRPC implementation with no external dependencies\n\n## 📝 Project Structure\n\nThis project sets up a complete environment for developing and testing Cosmo Router plugins:\n\n```\nproject-root/\n├── plugins/ # Contains all the plugins\n├── graph.yaml # Supergraph configuration\n├── config.json # Composed supergraph (generated)\n├── config.yaml # Router configuration\n├── release/ # Router binary location\n│ └── router # Router binary\n└── Makefile # Automation scripts\n```\n\n## 🚀 Getting Started\n\n### Setup\n\n1. Clone this repository\n2. Run the included Makefile commands\n\n### Available Make Commands\n\nThe Makefile automates the entire workflow with these commands:\n\n- `make`: Runs all commands in sequence (download, build, compose, start)\n- `make download`: Downloads the Cosmo Router binary to the `release` directory\n- `make build`: Builds the plugin from your source code with debug symbols enabled\n- `make generate`: Generates Go code from your GraphQL schema without compilation\n- `make test`: Validates your implementation with integration tests\n- `make compose`: Composes your supergraph from the configuration in `graph.yaml`\n- `make start`: Starts the Cosmo Router with your plugin\n\n### Quick Start\n\nTo get everything running with a single command:\n\n```bash\nmake\n```\n\nThis will:\n1. Download the Cosmo Router binary\n2. Build your plugin from source\n3. Compose your supergraph\n4. Start the router on port 3010\n\n## 🧪 Testing Your Plugin\n\nOnce running, open the GraphQL Playground at [http://localhost:3010](http://localhost:3010) and try this query:\n\n```graphql\nquery {\n hello(name: "World") {\n id\n name\n }\n}\n```\n\n## 🔧 Customizing Your Plugin\n\n1. Modify `src/schema.graphql` to define your GraphQL types and operations\n2. Edit `src/main.go` to implement the corresponding gRPC service methods\n3. Run `make generate` to regenerate code from your updated schema\n4. Run `make build` to compile your plugin\n5. Run `make test` to validate your implementation with integration tests\n6. Run `make compose` to update your supergraph\n7. Run `make start` to restart the router with your changes\n\n## 📚 Learn More\n\nFor more information about Cosmo and building router plugins:\n- [Cosmo Documentation](https://cosmo-docs.wundergraph.com/)\n- [Cosmo Router Plugins Guide](https://cosmo-docs.wundergraph.com/connect/plugins)\n\n---\n\n<p align="center">Made with ❤️ by <a href="https://wundergraph.com">WunderGraph</a></p>\n';
'# {name} - Cosmo Router Plugin Project\r\n\r\nDesign your API with GraphQL Federation and implement with gRPC using Cosmo Router Plugins\r\n\r\n## ✨ Features\r\n\r\n- **GraphQL Schema + gRPC Implementation**: Design your API with GraphQL SDL and implement it using gRPC methods\r\n- **Embedded Subgraphs**: Run subgraphs directly inside the Cosmo Router for improved performance\r\n- **End-to-End Type Safety**: Auto-generated Go code from your GraphQL schema\r\n- **Simplified Testing**: Unit test your gRPC implementation with no external dependencies\r\n\r\n## 📝 Project Structure\r\n\r\nThis project sets up a complete environment for developing and testing Cosmo Router plugins:\r\n\r\n```\r\nproject-root/\r\n├── plugins/ # Contains all the plugins\r\n├── graph.yaml # Supergraph configuration\r\n├── config.json # Composed supergraph (generated)\r\n├── config.yaml # Router configuration\r\n├── release/ # Router binary location\r\n│ └── router # Router binary\r\n└── Makefile # Automation scripts\r\n```\r\n\r\n## 🚀 Getting Started\r\n\r\n### Setup\r\n\r\n1. Clone this repository\r\n2. Run the included Makefile commands\r\n\r\n### Available Make Commands\r\n\r\nThe Makefile automates the entire workflow with these commands:\r\n\r\n- `make`: Runs all commands in sequence (download, build, compose, start)\r\n- `make download`: Downloads the Cosmo Router binary to the `release` directory\r\n- `make build`: Builds the plugin from your source code with debug symbols enabled\r\n- `make generate`: Generates Go code from your GraphQL schema without compilation\r\n- `make test`: Validates your implementation with integration tests\r\n- `make compose`: Composes your supergraph from the configuration in `graph.yaml`\r\n- `make start`: Starts the Cosmo Router with your plugin\r\n\r\n### Quick Start\r\n\r\nTo get everything running with a single command:\r\n\r\n```bash\r\nmake\r\n```\r\n\r\nThis will:\r\n1. Download the Cosmo Router binary\r\n2. Build your plugin from source\r\n3. Compose your supergraph\r\n4. Start the router on port 3010\r\n\r\n## 🧪 Testing Your Plugin\r\n\r\nOnce running, open the GraphQL Playground at [http://localhost:3010](http://localhost:3010) and try this query:\r\n\r\n```graphql\r\nquery {\r\n hello(name: "World") {\r\n id\r\n name\r\n }\r\n}\r\n```\r\n\r\n## 🔧 Customizing Your Plugin\r\n\r\n1. Modify `src/schema.graphql` to define your GraphQL types and operations\r\n2. Edit `src/main.go` to implement the corresponding gRPC service methods\r\n3. Run `make generate` to regenerate code from your updated schema\r\n4. Run `make build` to compile your plugin\r\n5. Run `make test` to validate your implementation with integration tests\r\n6. Run `make compose` to update your supergraph\r\n7. Run `make start` to restart the router with your changes\r\n\r\n## 📚 Learn More\r\n\r\nFor more information about Cosmo and building router plugins:\r\n- [Cosmo Documentation](https://cosmo-docs.wundergraph.com/)\r\n- [Cosmo Router Plugins Guide](https://cosmo-docs.wundergraph.com/connect/plugins)\r\n\r\n---\r\n\r\n<p align="center">Made with ❤️ by <a href="https://wundergraph.com">WunderGraph</a></p>\r\n';

const graphYaml =
'version: 1\nsubgraphs:\n # Add your other subgraphs here\n - plugin:\n version: 0.0.1\n path: plugins/{originalPluginName}\n';
'version: 1\r\nsubgraphs:\r\n # Add your other subgraphs here\r\n - plugin:\r\n version: 0.0.1\r\n path: plugins/{originalPluginName}\r\n';

const routerConfigYaml =
'# yaml-language-server: $schema=https://raw.githubusercontent.com/wundergraph/cosmo/main/router/pkg/config/config.schema.json\n\nversion: "1"\n\nlisten_addr: localhost:3010\n\ndev_mode: true\n\nexecution_config:\n file:\n path: config.json\n\nplugins:\n enabled: true\n path: plugins\n';
'# yaml-language-server: $schema=https://raw.githubusercontent.com/wundergraph/cosmo/main/router/pkg/config/config.schema.json\r\n\r\nversion: "1"\r\n\r\nlisten_addr: localhost:3010\r\n\r\ndev_mode: true\r\n\r\nexecution_config:\r\n file:\r\n path: config.json\r\n\r\nplugins:\r\n enabled: true\r\n path: plugins\r\n';

export default {
gitignore,
Expand Down
Loading