A demo showing how one Buf API can offer GraphQL, REST, gRPC, and Connect protocols, using a combination of Vanguard and Tailcall.
Inspired by this example.
Run the server on port 8080 with:
go run main.go
$ 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"
}
}
curl -v http://localhost:8080/bvr.v1beta1.FooService/CreateFoo \
-H "Content-Type: application/json" \
--data-binary @- <<EOF
{
"name": "BAR"
}
EOF
or
pkgx http http://localhost:8080/bvr.v1beta1.FooService/CreateFoo name="BAR"
Thanks to Tailcall, we've able to generate a GraphQL API from our
Vanguard HTTP APIs. (See tailcall.graphql
).
Once you've started the Tailcall server with:
pkgx tailcall start ./tailcall.graphql
You can visit the GraphQL Playground and run the following query:
{
foo(input: { id: "1" }) {
foo {
id
name
}
}
}