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
To start with we'll create ./app/graphql/launch.graphql
fragment LaunchDetails on Launch {idmission_namedetailslinks {flickr_imagesmission_patch}}fragment CargoWeightCapacity on Launch {rocket {rocket {payload_weights {idlb}}}}fragment CurrentCargoWeight on cargo_aggregate {aggregate {sum {weight}}}# Launch details when not logged inquery AnonymousLaunchDetails($id: ID!) {launch(id: $id) {...LaunchDetails}}# When logged in get both launch and cargo detailsquery UserLaunchDetails($id: ID!, $launchId: String!) {launch(id: $id) {...LaunchDetails...CargoWeightCapacity}# Notice we don't have to pass in userId, the permissions take care of itcargo(where: { launchId: { _eq: $launchId } }) {idweightname}cargo_aggregate(where: { launchId: { _eq: $launchId } }) {...CurrentCargoWeight}}# When we are about to add new cargo, we get info on the current cargoquery 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
Build apps and APIs 10x faster
Built-in authorization and caching
8x more performant than hand-rolled APIs

