Proposal: Ballerina GraphQL Schema Registry #4820
Labels
module/graphql
Issues related to Ballerina GraphQL module
Status/Active
Proposals that are under review
Team/PCM
Protocol connector packages related issues
Type/Proposal
Summary
A Schema Registry in GraphQL is crucial for maintaining a centralized repository of schemas in a Federated GraphQL Service, enabling efficient schema versioning and validation. Even though there are already implemented solutions, there is a shortage of open-source projects addressing that. This project aims to fill that gap by developing a Schema Registry as a Service using Ballerina.
Goals
Motivation
Federated GraphQL is needed over a Single large Schema to enable scalable, decentralized development and maintenance of microservices, allowing teams to work independently on their GraphQL schemas. The main three components of a Federated GraphQL service are,
When Subgraphs evolve independently, It is crucial to have a centralized mechanism to validate and document the changes made to the Supergraph. That’s where the Schema Registry comes in, Schema Registry helps in,
While there are solutions for creating Subgraphs and Router components, a critical missing piece in the ecosystem is an Open Source Schema Registry. Without a Schema Registry, managing schema changes and ensuring data consistency across federated GraphQL services becomes challenging, leading to potential compatibility issues.
This proposal aims to address this gap by introducing an Open Source Schema Registry using the Ballerina programming language. By implementing an Open Source Schema Registry, we will enhance the overall reliability and maintainability of Federated GraphQL architectures, fostering collaboration within the GraphQL community.
Description
The Schema Registry Service is provided as a Self-Hostable GraphQL service. And this will use the ‘Federation V2’ specification.
The client operations that will be provided are,
Architecture
Versioning Strategy
Changes made to the supergraph can be categorized into three categories as per the Operation Check and that can also be used to format of the Version number of the Supergraph in the format of
[Breaking].[Dangerous].[Safe]
Starting up the Schema Registry Service
Add the configurations of the Schema Registry to the
Config.toml
with the following,After building and running the Service, it will be available on http://localhost:PORT
Schema Registry Service - GraphQL API
Since this will be implemented as a GraphQL service, the GraphQL API for that will be as follows.
Validation Error Codes
In the API,
dryRun
query and thepublishSubgraph
mutation operations can return errors if either the Operation Checks or Composition Checks fail. So the Errors are categorized into two groups as Operation Check Errors and Composition Check Errors.Error response format will be as follows,
message
: Error Messagelocations
: Error locationpath
: Path to the field/type/argument where the error occurredextensions
phase
: Operation Check (DenotedOPERATION
) or Composition Check (DenotedCOMPOSITION
)code
: Error CodeInitial implementations of the Schema Registry will detect following errors on the two error categories as follows,
Operation Check Errors (Breaking Changes)
id
field of a Type fromInt!
toString!
)String
toInt
) or Add Non-Nullable to an existing argument (fromString
toString!
)String
toInt
) or Add Non-Nullable to an existing input type field (fromString
toString!
)Please note that this does not cover all possible Breaking Changes or Dangerous Changes that can happen to a Schema. They will be added gradually over the Development. All the possible changes that can happen to a Schema is as follows,
Object
type toScalar
type, ChangeInterface
type toEnum
type, Change Object type to Interface type)String!
toString
is Dangerous) OR TypeChange ? Breaking : Dangerous (String
toInt
is Breaking)String!
toString
is Dangerous) OR TypeChange ? Breaking : Dangerous (String
toInt
is Breaking)Composition Check Errors
NO_QUERIES
TYPE_KIND_MISMATCH
Object
type but another is anInterface
.)KEY_FIELDS_SELECT_INVALID_TYPE
fields
argument of@key
directive includes a field whose type is a list, interface, or union type. Fields of these types cannot be part of a@key
INVALID_FIELD_SHARING
Please note that this does not cover all possible Errors that can happen when composing a Supergraph. They will be added gradually over the Development. All possible errors can be found on this.
Implementation
Technologies
Schema Registry will be exposed as a GraphQL service, written in Ballerina. Initially the Schema Registry will use a Java based GraphQL Parser to parse GraphQL schemas due to limited time available. Later on, the existing Ballerina GraphQL document parser can be improved to parse GraphQL SDL.
Datasource
Initially File Based data storage will be used to store the data of the Schema Registry and it will be made in a Datasource Agnostic manner, so later users can use any datasource that they prefer to store the data.
Implementation Steps
Schema Registry will take an Incremental Development approach where,
Future Tasks
The text was updated successfully, but these errors were encountered: