The Movie Magic GraphQL Gateway is based on the gqlgen library for building GraphQL servers in Go. It was developed step-by-step starting from gqlgen Getting Started, which builds on top of a simple Todo schema. I later changed the schema to Movies for the final build. See the commit history for code progression. The gateway fetches movie data from Movie Magic Services, which exposes a gRPC endpoint.
This GraphQL gateway fetches data from Movie Magic Services in Go. Make sure that that server is running before starting this gateway.
- Make sure you have Go installed.
- In your shell, run
go run server.go
to start the server. - Open GraphiQL at http://localhost:8080
- Execute the following query:
# ----- query -----
query ListMovies($input: MoviesRequest!) {
movies(input: $input) {
movies {
id
name
cast {
person {
id
name
}
characters
}
certificate
genres
rank
releaseYear
ratingsSummary {
aggregateRating
}
}
pageInfo {
totalPages
totalItems
page
perPage
hasNextPage
hasPreviousPage
}
}
}
# ----- variables -----
{
"input": {
"sort": "SORT_PARAM_RANK_ASC",
"pageSpec": {
"page": 1,
"perPage": 10
}
}
}
You should see top 10 movies in the result.
go run github.com/99designs/gqlgen generate