This course is no longer maintained and may be out-of-date. While it remains available for reference, its content may not reflect the latest updates, best practices, or supported features.

Create the Launch Details Page GraphQL queries

githublaunch.graphql

To start with we'll create ./app/graphql/launch.graphql

fragment LaunchDetails on Launch {
id
mission_name
details
links {
flickr_images
mission_patch
}
}
fragment CargoWeightCapacity on Launch {
rocket {
rocket {
payload_weights {
id
lb
}
}
}
}
fragment CurrentCargoWeight on cargo_aggregate {
aggregate {
sum {
weight
}
}
}
# Launch details when not logged in
query AnonymousLaunchDetails($id: ID!) {
launch(id: $id) {
...LaunchDetails
}
}
# When logged in get both launch and cargo details
query UserLaunchDetails($id: ID!, $launchId: String!) {
launch(id: $id) {
...LaunchDetails
...CargoWeightCapacity
}
# Notice we don't have to pass in userId, the permissions take care of it
cargo(where: { launchId: { _eq: $launchId } }) {
id
weight
name
}
cargo_aggregate(where: { launchId: { _eq: $launchId } }) {
...CurrentCargoWeight
}
}
# When we are about to add new cargo, we get info on the current cargo
query CurrentCargoInfo($id: ID!, $launchId: String!) {
launch(id: $id) {
...CargoWeightCapacity
}
cargo_aggregate(where: { launchId: { _eq: $launchId } }) {
...CurrentCargoWeight
}
}
mutation AddCargo($cargo: cargo_insert_input!) {
insert_cargo_one(object: $cargo) {
id
}
}

Run npm run codegen

We use Graphql fragments and have different queries based on login status. We also have a single mutation to add cargo.

Did you find this page helpful?
Start with GraphQL on Hasura for Free
  • ArrowBuild apps and APIs 10x faster
  • ArrowBuilt-in authorization and caching
  • Arrow8x more performant than hand-rolled APIs
Promo
footer illustration
Brand logo
© 2025 Hasura Inc. All rights reserved
Github
Titter
Discord
Facebook
Instagram
Youtube
Linkedin
graphql-handbook