Skip to content

Commit 3c69e2c

Browse files
authored
Merge pull request #208 from magento-architects/graphql-schema-federation
Evaluation of Apollo schema federation for GraphQL
2 parents a08e67e + 574b423 commit 3c69e2c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## Apollo schema federation as an alternative to Magento schema stitching
2+
3+
Apollo [schema federation](https://www.apollographql.com/docs/apollo-server/federation/introduction/) is a replacement for their [schema stitching](https://www.apollographql.com/docs/graphql-tools/schema-stitching/). Schema federation is intended to:
4+
- Solve modularity and extensibility challenges of schema stitching
5+
- Allow code separation by concern
6+
- Provide support for distributed GraphQL
7+
8+
## Apollo federation vs Magento server-side schema stitching
9+
10+
Feature parity:
11+
- Modularity
12+
- Types extensibility
13+
- Separation of concerns
14+
15+
Benefits of Apollo Federation:
16+
- Works with microservice architecture
17+
- Mechanism for entity reference resolution between independent services
18+
19+
Concerns:
20+
- No implementation of federation gateway in PHP
21+
- Requires refactoring of existing schema. Potentially in a backward incompatible manner
22+
23+
## Migration path from Magento schema stitching to Apollo federation
24+
25+
To start supporting federated schema, we need to:
26+
1. Rewrite modular GraphQL schemas to include entity `@key` directives and type extensions using `extend type` syntax
27+
1. Implement federation gateway in PHP according to the [federation spec](https://www.apollographql.com/docs/apollo-server/federation/federation-spec/). Its responsibility is to generate final schema and execute federated queries (resolve references).
28+
29+
## Resolution
30+
Considering that Magento is a monolithic application which supports GraphQL schema modularity and extensibility using its custom implementation of server-side schema stitching algorithm, it does not make sense to implement schema federation yet. However, schema federation may be needed when Magento is decomposed into multiple domain services.
31+
32+

0 commit comments

Comments
 (0)