### gRPC Reflection CLI Examples Source: https://context7.com/kevinmichaelchen/buf-vanguard-rest/llms.txt Demonstrates how to use command-line tools like `grpcurl` and `buf curl` to interact with a gRPC service that supports reflection. These examples show how to list services, describe a specific service, and invoke methods dynamically without pre-compiled descriptors. ```bash # List available services using grpcurl grpcurl -plaintext localhost:8080 list # Output: # bvr.v1beta1.FooService # grpc.reflection.v1.ServerReflection # Describe the FooService grpcurl -plaintext localhost:8080 describe bvr.v1beta1.FooService # Call GetFoo using buf curl buf curl \ --protocol grpc \ --http2-prior-knowledge \ http://localhost:8080/bvr.v1beta1.FooService/GetFoo \ -d '{"id": "1"}' # Response { "foo": { "id": "1", "name": "Bar" } } ``` -------------------------------- ### Start Tailcall GraphQL Server Source: https://github.com/kevinmichaelchen/buf-vanguard-rest/blob/main/README.md Command to start the Tailcall server, which generates a GraphQL API from the specified configuration file (`tailcall.graphql`). This enables querying the backend services via GraphQL. ```shell pkgx tailcall start ./tailcall.graphql ``` -------------------------------- ### Run Go Server Source: https://github.com/kevinmichaelchen/buf-vanguard-rest/blob/main/README.md Starts the main server application using Go. This command is typically used for local development and testing. ```shell go run main.go ``` -------------------------------- ### GraphQL Query Example Source: https://github.com/kevinmichaelchen/buf-vanguard-rest/blob/main/README.md An example GraphQL query to fetch a 'foo' resource with its nested 'id' and 'name'. This query would be executed against the GraphQL endpoint provided by Tailcall. ```graphql { foo(input: { id: "1" }) { foo { id name } } } ``` -------------------------------- ### Make REST Request to Localhost Source: https://github.com/kevinmichaelchen/buf-vanguard-rest/blob/main/README.md Example of how to make a GET request to a local REST API endpoint running on port 8080. It demonstrates fetching data for a specific resource ('foos/1') and the expected JSON response. ```shell $ http localhost:8080/foos/1 HTTP/1.1 200 OK Accept-Encoding: gzip Content-Encoding: gzip Content-Length: 55 Content-Type: application/json Date: Sat, 13 Jan 2024 18:28:44 GMT { "foo": { "id": "1", "name": "Bar" } } ``` -------------------------------- ### Query Foo Resource via GraphQL API Source: https://context7.com/kevinmichaelchen/buf-vanguard-rest/llms.txt Shows how to query Foo resources using GraphQL, with the schema generated by Tailcall from REST endpoints. It includes the Tailcall configuration and an example GraphQL query to fetch specific fields of a Foo resource. The server is configured to listen on port 8000. ```graphql # Query configuration in tailcall.graphql schema @server(port: 8000, graphiql: true) @upstream(baseURL: "http://localhost:8080") { query: Query } type Query { foo(input: GetFooRequest!): GetFooResponse @http(path: "/foos/{{args.input.id}}") } ``` ```bash # Start the Tailcall GraphQL server tailcall start ./tailcall.graphql # Example GraphQL query curl -X POST http://127.0.0.1:8000/graphql \ -H "Content-Type: application/json" \ -d '{ "query": "{ foo(input: { id: \"1\" }) { foo { id name } } }" }' # Response { "data": { "foo": { "foo": { "id": "1", "name": "Bar" } } } } ``` -------------------------------- ### REST API: Get Foo Resource Source: https://context7.com/kevinmichaelchen/buf-vanguard-rest/llms.txt Retrieve a Foo resource by ID using a RESTful HTTP GET request. The endpoint follows REST conventions with the resource ID as a path parameter, automatically transcoded from the underlying gRPC service by Vanguard. ```APIDOC ## GET /foos/{id} ### Description Retrieve a Foo resource by ID. ### Method GET ### Endpoint /foos/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the Foo resource to retrieve. ### Request Example ```bash curl http://localhost:8080/foos/1 ``` ### Response #### Success Response (200) - **foo** (object) - The requested Foo resource. - **id** (string) - The ID of the Foo resource. - **name** (string) - The name of the Foo resource. #### Response Example ```json { "foo": { "id": "1", "name": "Bar" } } ``` ``` -------------------------------- ### Retrieve Foo Resource via REST API Source: https://context7.com/kevinmichaelchen/buf-vanguard-rest/llms.txt Demonstrates how to retrieve a Foo resource using a RESTful HTTP GET request to a specific endpoint. The ID is provided as a path parameter. This functionality is powered by Vanguard's automatic transcoding from the underlying gRPC service. ```bash # Retrieve a Foo resource with ID "1" curl http://localhost:8080/foos/1 # Response (200 OK) { "foo": { "id": "1", "name": "Bar" } } # With httpie for cleaner output http localhost:8080/foos/1 ``` -------------------------------- ### Create Foo Resource via Connect RPC Source: https://context7.com/kevinmichaelchen/buf-vanguard-rest/llms.txt Illustrates creating a new Foo resource using the Connect protocol, which employs standard HTTP with JSON payloads. The endpoint URL includes the fully-qualified service and method name. This method sends a POST request with the resource details. ```bash # Create a new Foo resource curl -v http://localhost:8080/bvr.v1beta1.FooService/CreateFoo \ -H "Content-Type: application/json" \ --data-binary @- <> GET http://localhost:8080/foos/1 HTTP/1.1 // #0001>> Accept: */* // #0001>> // #0001<< 200 OK // #0001<< Content-Type: application/json // #0001<< (42 bytes) ``` -------------------------------- ### GraphQL API: Query Foo Resource Source: https://context7.com/kevinmichaelchen/buf-vanguard-rest/llms.txt Query Foo resources using GraphQL, which is generated from the REST endpoints using Tailcall. The GraphQL schema provides a unified interface with type-safe queries and selective field retrieval. ```APIDOC ## GraphQL Endpoint ### Description Query Foo resources using GraphQL. ### Method POST ### Endpoint /graphql (on port 8000) ### Parameters #### Request Body - **query** (string) - Required - The GraphQL query string. ### Request Example ```json { "query": "{ foo(input: { id: \"1\" }) { foo { id name } } }" } ``` ### Response #### Success Response (200) - **data** (object) - The result of the GraphQL query. #### Response Example ```json { "data": { "foo": { "foo": { "id": "1", "name": "Bar" } } } } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.