Skip to content

Commit

Permalink
add json schemas for supergraph.yaml (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas authored Oct 22, 2024
1 parent cd60606 commit 1add31e
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/three-teachers-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vscode-apollo": patch
---

Add JSON schema for `supergraph.yaml`.
2 changes: 1 addition & 1 deletion .github/workflows/E2E.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
matrix:
version: ["1.90.0", "stable", "insiders"]
steps:
- run: sudo apt update && sudo apt install -y libasound2t64 libgbm1 libgtk-3-0 libnss3 xvfb expect
- run: sudo apt update && sudo apt install -y libasound2 libgbm1 libgtk-3-0 libnss3 xvfb expect
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@
{
"fileMatch": "apollo.config.yaml",
"url": "./schemas/apollo.config.schema.json"
},
{
"fileMatch": "supergraph.yaml",
"url": "./schemas/supergraph_config_schema.json"
}
],
"commands": [
Expand Down
119 changes: 119 additions & 0 deletions schemas/supergraph_config_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "SupergraphConfig",
"description": "The configuration for a single supergraph composed of multiple subgraphs.",
"type": "object",
"required": [
"subgraphs"
],
"properties": {
"federation_version": {
"anyOf": [
{
"$ref": "#/definitions/FederationVersion"
},
{
"type": "null"
}
]
},
"subgraphs": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/SubgraphConfig"
}
}
},
"definitions": {
"FederationVersion": {
"pattern": "^(1|2|=2\\.\\d+\\.\\d+.*)$"
},
"SchemaSource": {
"description": "Options for getting SDL: the graph registry, a file, or an introspection URL.\n\nNOTE: Introspection strips all comments and directives from the SDL.",
"anyOf": [
{
"type": "object",
"required": [
"file"
],
"properties": {
"file": {
"type": "string"
}
}
},
{
"type": "object",
"required": [
"subgraph_url"
],
"properties": {
"introspection_headers": {
"type": [
"object",
"null"
],
"additionalProperties": {
"type": "string"
}
},
"subgraph_url": {
"type": "string",
"format": "uri"
}
}
},
{
"type": "object",
"required": [
"graphref",
"subgraph"
],
"properties": {
"graphref": {
"type": "string"
},
"subgraph": {
"type": "string"
}
}
},
{
"type": "object",
"required": [
"sdl"
],
"properties": {
"sdl": {
"type": "string"
}
}
}
]
},
"SubgraphConfig": {
"description": "Config for a single [subgraph](https://www.apollographql.com/docs/federation/subgraphs/)",
"type": "object",
"required": [
"schema"
],
"properties": {
"routing_url": {
"description": "The routing URL for the subgraph. This will appear in supergraph SDL and instructs the graph router to send all requests for this subgraph to this URL.",
"type": [
"string",
"null"
]
},
"schema": {
"description": "The location of the subgraph's SDL",
"allOf": [
{
"$ref": "#/definitions/SchemaSource"
}
]
}
}
}
}
}

0 comments on commit 1add31e

Please sign in to comment.