-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: add URL to the global namespace. (#446)
New functionality exposed in federation relies on the URL type being available.
- Loading branch information
1 parent
fcbd2f1
commit a0d7b4a
Showing
12 changed files
with
78 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
globalThis.URL = require("url").URL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
globalThis.URL = require("url").URL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// @ts-nocheck | ||
|
||
const assertEq = (a: unknown, b: unknown) => { | ||
if (a !== b) { | ||
throw `${a} is not equal to ${b}`; | ||
} | ||
}; | ||
|
||
const url = new URL("https://www.test.com/test2"); | ||
|
||
assertEq("/test2", url.pathname); | ||
assertEq("www.test.com", url.hostname); | ||
assertEq("https", url.scheme); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...ration-2/supergraph/src/command/snapshots/supergraph__command__compose__compose_test.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
source: supergraph/src/command/compose.rs | ||
expression: result | ||
--- | ||
{ | ||
"Ok": { | ||
"supergraphSdl": "schema\n @link(url: \"https://specs.apollo.dev/link/v1.0\")\n @link(url: \"https://specs.apollo.dev/join/v0.4\", for: EXECUTION)\n @join__directive(graphs: [TEST], name: \"link\", args: {url: \"https://specs.apollo.dev/source/v0.1\", import: [\"@sourceAPI\", \"@sourceType\", \"@sourceField\"], for: \"EXECUTION\"})\n @join__directive(graphs: [TEST], name: \"sourceAPI\", args: {name: \"json\", http: {baseURL: \"http://a.co/\"}})\n{\n query: Query\n}\n\ndirective @join__directive(graphs: [join__Graph!], name: String!, args: join__DirectiveArguments) repeatable on SCHEMA | OBJECT | INTERFACE | FIELD_DEFINITION\n\ndirective @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE\n\ndirective @join__field(graph: join__Graph, requires: join__FieldSet, provides: join__FieldSet, type: String, external: Boolean, override: String, usedOverridden: Boolean, overrideLabel: String) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION\n\ndirective @join__graph(name: String!, url: String!) on ENUM_VALUE\n\ndirective @join__implements(graph: join__Graph!, interface: String!) repeatable on OBJECT | INTERFACE\n\ndirective @join__type(graph: join__Graph!, key: join__FieldSet, extension: Boolean! = false, resolvable: Boolean! = true, isInterfaceObject: Boolean! = false) repeatable on OBJECT | INTERFACE | UNION | ENUM | INPUT_OBJECT | SCALAR\n\ndirective @join__unionMember(graph: join__Graph!, member: String!) repeatable on UNION\n\ndirective @link(url: String, as: String, for: link__Purpose, import: [link__Import]) repeatable on SCHEMA\n\ninput HTTPHeaderMapping\n @join__type(graph: TEST)\n{\n name: String!\n as: String\n value: String\n}\n\ninput HTTPSourceAPI\n @join__type(graph: TEST)\n{\n baseURL: String!\n headers: [HTTPHeaderMapping!]\n}\n\ninput HTTPSourceField\n @join__type(graph: TEST)\n{\n GET: source__URLPathTemplate\n POST: source__URLPathTemplate\n PUT: source__URLPathTemplate\n PATCH: source__URLPathTemplate\n DELETE: source__URLPathTemplate\n body: source__JSONSelection\n headers: [HTTPHeaderMapping!]\n}\n\ninput HTTPSourceType\n @join__type(graph: TEST)\n{\n GET: source__URLPathTemplate\n POST: source__URLPathTemplate\n headers: [HTTPHeaderMapping!]\n body: source__JSONSelection\n}\n\nscalar join__DirectiveArguments\n\nscalar join__FieldSet\n\nenum join__Graph {\n TEST @join__graph(name: \"test\", url: \"http://localhost:4000/graphql\")\n}\n\ninput KeyTypeMap\n @join__type(graph: TEST)\n{\n key: String!\n typeMap: source__TypenameKeyMap\n}\n\nscalar link__Import\n\nenum link__Purpose {\n \"\"\"\n `SECURITY` features provide metadata necessary to securely resolve fields.\n \"\"\"\n SECURITY\n\n \"\"\"\n `EXECUTION` features provide metadata necessary for operation execution.\n \"\"\"\n EXECUTION\n}\n\ntype Query\n @join__type(graph: TEST)\n{\n users: [User] @join__directive(graphs: [TEST], name: \"sourceField\", args: {api: \"json\", http: {GET: \"/users\"}, selection: \"id name\"})\n}\n\nscalar source__JSONSelection\n @join__type(graph: TEST)\n\nscalar source__TypenameKeyMap\n @join__type(graph: TEST)\n\nscalar source__URLPathTemplate\n @join__type(graph: TEST)\n\ntype User\n @join__type(graph: TEST)\n{\n id: ID!\n name: String\n}", | ||
"hints": [] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
federation_version: =2.7.0 | ||
subgraphs: | ||
test: | ||
name: test | ||
routing_url: "http://localhost:4000/graphql" | ||
schema: | ||
sdl: | | ||
extend schema | ||
@link(url: "https://specs.apollo.dev/federation/v2.7", import: ["@key"]) | ||
@link( | ||
url: "https://specs.apollo.dev/source/v0.1" | ||
import: ["@sourceAPI", "@sourceType", "@sourceField"] | ||
for: EXECUTION | ||
) | ||
@sourceAPI(name: "json", http: { baseURL: "http://a.co/" }) | ||
type Query { | ||
users: [User] | ||
@sourceField(api: "json", http: { GET: "/users" }, selection: "id name") | ||
} | ||
type User { | ||
id: ID! | ||
name: String | ||
} |