GraphQL Migration: A Proper Use Case for Metaprogramming?
summary
Proposes metaprogramming GraphQL Ruby to auto-generate GraphQL types and query boilerplate from existing target wrapper classes, using graphql-ruby gem, annotate_field metadata, unbound methods, dynamic method defs, class_eval and constants. Delivers a working prototype that generates Payment/Merchant/Card types, adapts when a Card target is added, and narrows public route types for permission changes. Tests use RSpec against the GraphQL type generator. Notes performance tradeoffs (schema loads per query; resolvers must be fast) but shows reduced boilerplate and improved developer experience.
AI-written summary · about
chapters (19)
- 0:00Introduction
- 0:25About me
- 1:40Square ecosystem
- 5:33Roadmap
- 6:03Regulators
- 7:08Targets
- 8:30Merchant ID
- 9:04Create GraphQL API
- 11:52Benefits of GraphQL Migration
- 13:37GraphQL Annotations
- 16:29Generate GraphQL
- 17:07Ruby Object Model Constants
- 19:21GraphQL Type Classes
- 21:39Demo
- 23:12New Target
- 24:27Requirement Change
- 26:16Testing
- 27:16Recap
- 29:08Questions







