artsy / metaphysics

Artsy's GraphQL API
MIT License
360 stars 89 forks source link

feat: add contextModule property to HomeViewSection type #6004

Closed dblandin closed 1 month ago

dblandin commented 1 month ago

This PR adds a new string attribute, contextModule, to the HomeViewSection type in order to provide clients with a consistent label for use in analytics event payloads.

We had previously experimented with inferring this label from the section internal IDs but I think decoupling the two gives us more stability and flexibility as the Home View architecture matures.

Note: The second commit in this PR switches from hard-coded strings to imports from our @artsy/cohesion package. This would introduce a dependency on cohesion for properly typing new section definition but I don't think would add considerably friction to the process overall. Open for debate though. cc/ @joeyAghion

Request

{
  homeView {
    sectionsConnection(first: 5) {
      edges {
        node {
          __typename
          ... on HomeViewSectionGeneric {
            component {
              title
            }
            contextModule
          }
        }
      }
    }
  }
}

Response

{
  "data": {
    "homeView": {
      "sectionsConnection": {
        "edges": [
          {
            "node": {
              "__typename": "HomeViewSectionActivity",
              "component": {
                "title": "Latest Activity"
              },
              "contextModule": "activityRail"
            }
          },
          {
            "node": {
              "__typename": "HomeViewSectionArtworks",
              "component": {
                "title": "New works for you"
              },
              "contextModule": "newWorksForYouRail"
            }
          },
          {
            "node": {
              "__typename": "HomeViewSectionHeroUnits",
              "component": null,
              "contextModule": "heroUnitsRail"
            }
          },
          {
            "node": {
              "__typename": "HomeViewSectionArtworks",
              "component": {
                "title": "Your Active Bids"
              },
              "contextModule": "yourActiveBids"
            }
          },
          {
            "node": {
              "__typename": "HomeViewSectionArtworks",
              "component": {
                "title": "Auction lots for you"
              },
              "contextModule": "lotsForYouRail"
            }
          }
        ]
      }
    }
  }
}