Slide 1

Slide 1 text

GraphQL Hive Workshop Laurin Quast Safely Evolve your Federated GraphQL Schema @n1rual Tuesday, Sep 19 2023 @n1ru4l Kamil Kisiela @kamilkisiela @kamilkisiela

Slide 2

Slide 2 text

1. (Intro) Evolving GraphQL can be Hard 2. Schema Registry 3. Breaking Change Detection 4. Usage Reporting 5. Conditional Breaking Changes 6. Q&A Workshop Agenda

Slide 3

Slide 3 text

Workshop Material https://github.com/n1ru4l/hive-workshop

Slide 4

Slide 4 text

Evolving GraphQL Can Be Hard

Slide 5

Slide 5 text

A Single Pull Request GraphQL can be easy The simple Setup Update GraphQL Schema Update GraphQL Operations Deploy • Rolling out changes is simple • Breaking clients does not happen (?)

Slide 6

Slide 6 text

Internal External GraphQL can be hard The Complex Setup • Many teams/products/developers • GraphQL API and Client(s) owned by different Teams • Code is spread across different repositories or even companies GraphQL Client GraphQL Client GraphQL Client GraphQL API GraphQL Client

Slide 7

Slide 7 text

Breaking Changes 💣

Slide 8

Slide 8 text

Laurin lives in undefined.

Slide 9

Slide 9 text

{user.name} lives in {user.hometown}

Slide 10

Slide 10 text

REST Style API Breaking Change Deploy

Slide 11

Slide 11 text

GraphQL Schema and Operations

Slide 12

Slide 12 text

Schema Change: Example 1

Slide 13

Slide 13 text

Schema Change: Example 2

Slide 14

Slide 14 text

Schema Change: Example 3

Slide 15

Slide 15 text

Schema Change: Example 4

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Schema Changes Are Dangerous And Can Break Clients

Slide 19

Slide 19 text

Git Workflow Develop Iterate on code according to CI feedback CI (GitHub Action) CD (GitHub Action) Check if code works Deploy code to production

Slide 20

Slide 20 text

Git Workflow Develop iterate on code according to CI feedback CI (GitHub Action) CD (GitHub Action) • Validate Schema • Detect Breaking Changes • Report CI Status GraphQL Inspector

Slide 21

Slide 21 text

Federated / Composite Schemas The Complex Setup • Composition should not fail in production (Gateway must be reliable) • Schema changes should be trackable • Subgraphs might not be within the same Git Repository GraphQL API GraphQL API GraphQL API Supergraph GraphQL API

Slide 22

Slide 22 text

Schema Registry

Slide 23

Slide 23 text

Schema Registry • Centralised repository for managing and validating GraphQL schemas • Validate and subgraph schemas • Schema history (Version control for GraphQL) • Categorisation of schema changes (breaking, safe, conditional breaking)

Slide 24

Slide 24 text

Workflow Develop iterate on code according to CI feedback CI (GitHub Action) CD (GitHub Action) GraphQL Hive Schema Registry GraphQL Hive Schema Registry • Verify schema integrity • Compose Supergraph (if needed) • Detect breaking changes • Report CI status • Persist schema history • Write supergraph to CDN (if needed)

Slide 25

Slide 25 text

Git Workflow Develop iterate on code according to CI feedback CI (GitHub Action) CD (GitHub Action) GraphQL Hive Schema Registry GraphQL Hive Schema Registry • Verify schema integrity • Compose Supergraph • Detect breaking changes • Report CI status • Persist schema history • Write supergraph to CDN

Slide 26

Slide 26 text

Git Workflow Develop iterate on code according to CI feedback CI (GitHub Action) CD (GitHub Action) GraphQL Hive Schema Registry GraphQL Hive Schema Registry • Verify schema integrity • Compose Supergraph • Detect breaking changes • Report CI status • Persist schema history • Write supergraph to CDN

Slide 27

Slide 27 text

GitHub Workflow Develop iterate on code according to CI feedback hive check • verify schema integrity • no breaking changes • enforce best practices hive publish • publish new schema • inform gateways • inform consumers CI (GitHub Action) CD (GitHub Action) GraphQL Hive Schema Registry GraphQL Hive Schema Registry

Slide 28

Slide 28 text

GitHub Workflow Develop iterate on code according to CI feedback hive check • verify schema integrity • no breaking changes • enforce best practices hive publish • publish new schema • inform gateways • inform consumers CI (GitHub Action) CD (GitHub Action) GraphQL Hive Schema Registry GraphQL Hive Schema Registry

Slide 29

Slide 29 text

Git Workflow Develop iterate on code according to CI feedback hive check • verify schema integrity • no breaking changes • enforce best practices hive publish • publish new schema • inform gateways • inform consumers CI (GitHub Action) CD (GitHub Action) GraphQL Hive Schema Registry GraphQL Hive Schema Registry

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

Deployment Flow Continious Deployment GraphQL Hive Schema Registry GraphQL Gateway Apollo Router Poll super graph from registry Deploy Subgraph Subgraph 1 Subgraph 2 Subgraph 3 Publish subgraph schema to registry Query subgraphs

Slide 39

Slide 39 text

Usage Reporting

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

Usage Reporting SDK GraphQL API Hive SDK • JavaScript • Ruby • Java • Custom GraphQL Hive Report schema usage

Slide 44

Slide 44 text

Usage Reporting SDK GraphQL API Hive SDK • JavaScript • Ruby • Java • Custom GraphQL Hive Report schema usage

Slide 45

Slide 45 text

Apollo Router Apollo Router Hive Apollo Router Plugin GraphQL Hive Report schema usage

Slide 46

Slide 46 text

Conditional Breaking Changes

Slide 47

Slide 47 text

Conditional Breaking Changes • Mark breaking changes as safe changes based on schema usage • If a fi eld is not used for N days, it is safe to remove it

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

Other Features • SSO (Okta, Auth0, etc.) built-in • All Cloud Features are available on Self-Hosted

Slide 50

Slide 50 text

Q&A Laurin Quast @n1rual @n1ru4l Kamil Kisiela @kamilkisiela @kamilkisiela Workshop Material https://github.com/n1ru4l/hive-workshop