6. Exercise 2: Deploy a subgraph change
1m

Exercise 2: Deploy a subgraph change ( 10 min)

Goal: Deploy a change, then fix errors.

Add a new field to the subgraph

You can do this using your local code editor, or with the GitHub UI.

  1. Open up the products/products.yaml file.

  2. Find the Query.product Connector and its selection parameter. Edit the file to add a new selection called category.

    products.yaml
    type Query {
    product(id: ID!): Product
    @connect(
    source: "ecomm"
    http: { GET: "/products/{$args.id}" }
    selection: "id name description category"
    entity: true
    )
    }

    If you've used before, you might know this change will result in an error... but let's see what happens if this change was allowed to go through.

Find the problem

  1. In a terminal window, run the following command to explore the logs for the Apollo Operator:

    kubectl -n apollo-operator logs deployment/apollo-operator

    You should see some errors. In production, this would be caught by standard alerting tools.

    You can also check the logs through Argo CD.

  2. Open up your graph in Studio.

  3. Click on Launches and find the failed .

  4. Click on View Build Errors to see the errors.

Fix the problem

  1. Open up the products/products.yaml file again.

  2. Fix the error by adding a category to the Product type.

    products.yaml
    type Product @key(fields: "id") {
    id: ID!
    name: String
    description: String
    category: String
    }
  3. Commit your changes and push them to the main branch.

  4. After a short delay, the will re-deploy. You may need to re-run the port-forward commands again.

    kubectl -n apollo-operator port-forward service/router-retail 4000:80
    kubectl -n argocd port-forward service/argocd-server 8080:80
  5. Open up your graph in Studio and go to the Explorer page.

  6. Run the to see category data come back.

query {
product(id: "1") {
id
name
description
category
}
}
Task!
Previous