|
| 1 | +--- |
| 2 | +title: "Building a Unified Financial API: Wealthsimple's Hive Implementation" |
| 3 | +excerpt: |
| 4 | + 'As the company scaled, the need for a robust, flexible, and efficient API architecture became |
| 5 | + paramount, leading to the adoption of GraphQL with Hive as their central API management solution.' |
| 6 | +category: Finance |
| 7 | +# We would need to go through approval to get author images. I guess we can leave this as is for now. |
| 8 | +authors: |
| 9 | + - name: |
| 10 | + position: |
| 11 | + avatar: |
| 12 | +--- |
| 13 | + |
| 14 | +import { DocsIcon, LargeCallout } from '#components/large-callout' |
| 15 | +import { Lede } from '#components/lede' |
| 16 | +import { SmallAvatar } from '#components/small-avatar' |
| 17 | +import { CallToAction, ContactButton } from '@theguild/components' |
| 18 | + |
| 19 | +[Wealthsimple](https://www.wealthsimple.com/en-ca) is one of Canada's fastest growing financial |
| 20 | +institutions and offers a full suite of simple, sophisticated financial products. As the company |
| 21 | +scaled, the need for a robust, flexible, and efficient API architecture became paramount, leading to |
| 22 | +the adoption of GraphQL with Hive as their central API management solution. |
| 23 | + |
| 24 | +## Challenges |
| 25 | + |
| 26 | +The primary challenges that led Wealthsimple to seek a GraphQL solution included: |
| 27 | + |
| 28 | +1. **Service Integration Complexity** |
| 29 | + |
| 30 | +- Managing a distributed architecture with many microservices |
| 31 | +- Need for comprehensive usage analytics beyond basic performance monitoring |
| 32 | +- Coordinating API changes across multiple development teams |
| 33 | +- Ensuring consistent performance regardless of customer profile |
| 34 | + |
| 35 | +2. **Development Workflow** |
| 36 | + |
| 37 | +- Lack of visibility into API usage patterns |
| 38 | +- Difficulty in tracking deprecated field usage |
| 39 | +- No systematic way to validate schema changes |
| 40 | +- Coordinating between multiple client applications (mobile and web) |
| 41 | + |
| 42 | +## Architecture |
| 43 | + |
| 44 | +### GraphQL Gateway |
| 45 | + |
| 46 | +At the heart of the system lies a centralized GraphQL gateway that serves as the primary entry point |
| 47 | +for all client applications. Built with TypeScript and Node.js, this gateway acts as an intelligent |
| 48 | +router, orchestrating requests across the service landscape. The gateway implements |
| 49 | +[schema stitching](https://the-guild.dev/graphql/stitching) to unify microservice schemas into a |
| 50 | +cohesive API surface. |
| 51 | + |
| 52 | +### Service Layer |
| 53 | + |
| 54 | +The underlying service layer comprises domain-specific services, representing different areas of |
| 55 | +Wealthsimple's financial ecosystem. Most services are built in Ruby, with a small subset using other |
| 56 | +technologies. These services use a mixed architecture approach, where some endpoints expose GraphQL |
| 57 | +interfaces while others maintain REST APIs. To seamlessly integrate REST services, the gateway |
| 58 | +utilizes Apollo data sources, ensuring consistent data access patterns. The team has also developed |
| 59 | +specialized components, including a custom Spring bean for reporting usage metrics to GraphQL Hive. |
| 60 | + |
| 61 | +<div> |
| 62 | + > Hive enables Wealthsimple to build flexible and resilient GraphQL APIs. The GitHub integration |
| 63 | + provides feedback in a format developers are familiar with and conditional breaking changes enable |
| 64 | + us to focus our discussion on schema design rather than maintenance. Hive empowers us to |
| 65 | + confidently evolve our schemas by ensuring seamless API updates, detecting potential breaking |
| 66 | + changes, and guiding developers. |
| 67 | +</div> |
| 68 | + |
| 69 | +## Implementation |
| 70 | + |
| 71 | +The implementation focused on two key areas: |
| 72 | + |
| 73 | +1. **Usage Analytics Integration** |
| 74 | + |
| 75 | +- Implemented complementary tracking alongside existing Datadog setup |
| 76 | +- Enhanced GraphQL usage monitoring capabilities: |
| 77 | + - Client-specific query tracking |
| 78 | + - Detailed operation body analysis |
| 79 | + - Real-time usage statistics |
| 80 | + |
| 81 | +2. **Schema Validation System** |
| 82 | + |
| 83 | +- Established global policy for schema changes |
| 84 | +- Implemented 30-day field usage monitoring |
| 85 | +- Integrated real-time developer feedback system |
| 86 | +- Set up automated validation checks for breaking changes |
| 87 | + |
| 88 | +## Results & Benefits |
| 89 | + |
| 90 | +The implementation has delivered several significant benefits: |
| 91 | + |
| 92 | +1. **Enhanced Development Workflow** |
| 93 | + |
| 94 | +- Data-driven decision making for schema changes. |
| 95 | +- Prevented potentially breaking changes through usage analysis. |
| 96 | +- Improved developer confidence in schema modifications. |
| 97 | + |
| 98 | +2. **Operational Improvements** |
| 99 | + |
| 100 | +- Better visibility into API usage patterns. |
| 101 | +- Reduced risk of breaking changes. |
| 102 | +- More efficient schema management. |
| 103 | + |
| 104 | +<LargeCallout |
| 105 | + icon={<DocsIcon />} |
| 106 | + heading="Comprehensive Query Insights" |
| 107 | + variant="secondary" |
| 108 | + cta={ |
| 109 | + <CallToAction variant="tertiary" href="/docs/dashboard/insights"> |
| 110 | + Learn More |
| 111 | + </CallToAction> |
| 112 | + } |
| 113 | +> |
| 114 | + Get a detailed view of all GraphQL operations executed by your consumers, including performance |
| 115 | + metrics and total counts. Click on any specific query to explore the full list of fields and |
| 116 | + arguments used in the operation. |
| 117 | +</LargeCallout> |
| 118 | + |
| 119 | +## Lessons Learned |
| 120 | + |
| 121 | +1. **Schema Validation Impact** |
| 122 | + |
| 123 | + Schema validation has helped Wealthsimple's API development process by enabling data-driven |
| 124 | + decisions based on actual usage patterns. This shift from guesswork to quantifiable insights has |
| 125 | + allowed teams to confidently evolve the API while maintaining stability for existing clients. |
| 126 | + |
| 127 | +2. **Integration Considerations** |
| 128 | + |
| 129 | + Cross-platform integration has positioned Wealthsimple as an active contributor to the |
| 130 | + open-source community, where they now maintain the official |
| 131 | + [GraphQL Hive Ruby client](https://github.com/rperryng/graphql-ruby-hive?tab=readme-ov-file#graphql-hive-graphql-ruby-integration). |
| 132 | + This commitment to open-source development not only supports their own cross-platform needs but |
| 133 | + also benefits the broader GraphQL ecosystem. Their experience demonstrates the importance of both |
| 134 | + consuming and contributing to open-source tools while building a robust financial platform. |
| 135 | + |
| 136 | +## Future Plans |
| 137 | + |
| 138 | +1. **Schema Registry Migration** |
| 139 | + |
| 140 | + Wealthsimple plans to transition away from their existing git-ops system in favor of Hive's |
| 141 | + comprehensive schema registry feature. This strategic move will modernize their schema management |
| 142 | + process by providing a centralized, automated system for schema validation and distribution. This |
| 143 | + migration represents a key step in Wealthsimple's broader initiative to enhance their API |
| 144 | + infrastructure and developer experience. |
| 145 | + |
| 146 | +2. **Security Infrastructure Enhancement** |
| 147 | + |
| 148 | + Wealthsimple is implementing |
| 149 | + [Hive's App Deployments feature](https://the-guild.dev/graphql/hive/docs/schema-registry/app-deployments) |
| 150 | + to optimize performance and track API usage against app versions. This solution will restrict API |
| 151 | + access to predefined queries only and implement a query hash system for network optimization. |
| 152 | + |
| 153 | +3. **Gateway Evolution** |
| 154 | + |
| 155 | + Wealthsimple is improving its API gateway infrastructure by focusing on migrating from their |
| 156 | + current Apollo server with schema stitching to Hive Gateway. Having already tested |
| 157 | + [GraphQL Yoga](https://the-guild.dev/graphql/yoga-server) in staging with |
| 158 | + [promising performance gains](https://the-guild.dev/graphql/yoga-server/docs/comparison#better-runtime-performance), |
| 159 | + the team is now working on adopting Hive Gateway to enable a gradual transition to |
| 160 | + [federation](https://the-guild.dev/graphql/hive/federation). This approach will allow teams to |
| 161 | + maintain ownership of their schemas while enabling a methodical, type-by-type migration from the |
| 162 | + existing stitched schema setup to a federated architecture. |
| 163 | + |
| 164 | +<LargeCallout |
| 165 | + icon={<DocsIcon />} |
| 166 | + heading="Elevate Your GraphQL Journey" |
| 167 | + variant="primary" |
| 168 | + cta={<ContactButton variant="secondary-inverted" />} |
| 169 | +> |
| 170 | + Transform your API infrastructure like Wealthsimple. Whether it's migrating to a centralized |
| 171 | + schema registry, enhancing security, or evolving your gateway architecture, our tools and |
| 172 | + expertise can help you achieve your goals efficiently. |
| 173 | +</LargeCallout> |
| 174 | + |
| 175 | +## Conclusion |
| 176 | + |
| 177 | +Wealthsimple's implementation of GraphQL with Hive has proven to be a successful strategic decision, |
| 178 | +providing enhanced visibility, improved development workflows, and a solid foundation for future |
| 179 | +scaling. The company's positive experience with the platform has led to expanded usage plans and |
| 180 | +continued investment in the GraphQL ecosystem. The gradual, thoughtful approach to migration and |
| 181 | +feature adoption has enabled the team to maintain stability while advancing their technical |
| 182 | +capabilities. |
0 commit comments