Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
8618e06
bigan
enisdenjo May 26, 2025
9871737
begin
enisdenjo May 26, 2025
1380a58
start setting up tests
enisdenjo Jun 9, 2025
bb9ad3a
lets try node froid
enisdenjo Jun 9, 2025
09b9ce6
global object ident
enisdenjo Jun 9, 2025
696e55a
revert getstitched
enisdenjo Jun 9, 2025
4ca1d97
begin
enisdenjo Jun 9, 2025
992a6d7
schema with node
enisdenjo Jun 9, 2025
23f0c36
point to graphql org
enisdenjo Jun 9, 2025
80dede9
unused
enisdenjo Jun 9, 2025
2e5e663
resolve basic person hardcoded
enisdenjo Jun 9, 2025
1a0a0d1
progress progress
enisdenjo Jun 10, 2025
f8c5400
handle multiple fields keys
enisdenjo Jun 10, 2025
9904c23
people
enisdenjo Jun 10, 2025
a092309
test for nodeid
enisdenjo Jun 10, 2025
a3e6c23
resolve nodeId
enisdenjo Jun 10, 2025
c52d431
accounts
enisdenjo Jun 10, 2025
a074530
multiple fields key
enisdenjo Jun 10, 2025
07fcd8a
use additional resolvers, better
enisdenjo Jun 10, 2025
b5cdb7c
handle remainders
enisdenjo Jun 11, 2025
5ec5fbf
batch deleg
enisdenjo Jun 11, 2025
55c410f
option
enisdenjo Jun 11, 2025
bff6b2b
merge resolvers
enisdenjo Jun 11, 2025
2a0ff27
global object ident e2e
enisdenjo Jun 11, 2025
c77d0ea
specify return type
enisdenjo Jun 11, 2025
c3c5449
resolve from other subgraphs too
enisdenjo Jun 12, 2025
d9d5509
correct returntype
enisdenjo Jun 12, 2025
6f0c11a
changeseet
enisdenjo Jun 12, 2025
64f3817
chore(dependencies): updated changesets for modified dependencies
github-actions[bot] Jun 12, 2025
b35033b
resolve func
enisdenjo Jun 12, 2025
b5cbb77
node id without dependant fields
enisdenjo Jun 12, 2025
44f4a9a
add graphl
enisdenjo Jun 12, 2025
db46408
no generator
enisdenjo Jun 12, 2025
d865803
properly merge resolvers
enisdenjo Jun 12, 2025
bd7834d
simpler lol
enisdenjo Jun 12, 2025
e7e9e64
improve tests
enisdenjo Jun 12, 2025
3ecd0fa
interfaces should implement node too
enisdenjo Jun 12, 2025
96e0a18
improvements
enisdenjo Jun 13, 2025
68b99cb
interface support
enisdenjo Jun 23, 2025
ac30464
configurable
enisdenjo Jun 23, 2025
1561952
nodeidfield in args
enisdenjo Jun 23, 2025
1cf5266
no Query.nodes for now
enisdenjo Jun 23, 2025
2d32ff6
configurable from/to id
enisdenjo Jun 23, 2025
528b9ad
no node collision
enisdenjo Jun 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/@graphql-tools_federation-1232-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@graphql-tools/federation': patch
---

dependencies updates:

- Added dependency [`@graphql-tools/batch-delegate@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-tools/batch-delegate/v/workspace:^) (to `dependencies`)
- Added dependency [`graphql-relay@^0.10.2` ↗︎](https://www.npmjs.com/package/graphql-relay/v/0.10.2) (to `dependencies`)
37 changes: 37 additions & 0 deletions .changeset/rare-pants-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
'@graphql-mesh/fusion-runtime': minor
'@graphql-tools/federation': minor
'@graphql-hive/gateway-runtime': minor
---

Automatic Global Object Identification

Setting the `globalObjectIdentification` option to true will automatically implement the
GraphQL Global Object Identification Specification by adding a `Node` interface and `node(id: ID!): Node` field to the `Query` type.

The `Node` interface will have a `nodeId` (not `id`!) field used as the global identifier. It
is intentionally not `id` to avoid collisions with existing `id` fields in subgraphs.

```graphql
"""
An object with a globally unique `ID`.
"""
interface Node {
"""
A globally unique identifier. Can be used in various places throughout the system to identify this single value.
"""
nodeId: ID!
}

extend type Query {
"""
Fetches an object given its globally unique `ID`.
"""
node(
"""
The globally unique `ID`.
"""
nodeId: ID!
): Node
}
```
5 changes: 5 additions & 0 deletions e2e/global-object-identification/gateway.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineConfig } from '@graphql-hive/gateway';

export const gatewayConfig = defineConfig({
globalObjectIdentification: true,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { createExampleSetup, createTenv } from '@internal/e2e';
import { toGlobalId } from 'graphql-relay';
import { expect, it } from 'vitest';

const { gateway } = createTenv(__dirname);
const { supergraph, query, result } = createExampleSetup(__dirname);

it('should execute as usual', async () => {
const { execute } = await gateway({
supergraph: await supergraph(),
});
await expect(
execute({
query,
}),
).resolves.toEqual(result);
});

it('should find objects through node', async () => {
const { execute } = await gateway({
supergraph: await supergraph(),
});
await expect(
execute({
query: /* GraphQL */ `
query ($nodeId: ID!) {
node(nodeId: $nodeId) {
... on Product {
nodeId
upc
name
price
weight
}
}
}
`,
variables: {
nodeId: toGlobalId('Product', '2'),
},
}),
).resolves.toMatchInlineSnapshot(`
{
"data": {
"node": {
"name": "Couch",
"nodeId": "UHJvZHVjdDoy",
"price": 1299,
"upc": "2",
"weight": 1000,
},
},
}
`);
});
8 changes: 8 additions & 0 deletions e2e/global-object-identification/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@e2e/global-object-identification",
"private": true,
"dependencies": {
"graphql": "^16.11.0",
"graphql-relay": "^0.10.2"
}
}
5 changes: 4 additions & 1 deletion packages/batch-delegate/src/getLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ function createBatchFn<K = any>(options: BatchDelegateOptions) {
.then(() =>
delegateToSchema({
returnType: new GraphQLList(
getNamedType(options.returnType || options.info.returnType),
getNamedType(
// options.returnType || // if the returnType is provided by options, it'll override this property because of the spread below. it was like this since forever, so lets keep it for backwards compatibility
options.info.returnType,
),
),
onLocatedError: (originalError) => {
if (originalError.path == null) {
Expand Down
2 changes: 2 additions & 0 deletions packages/federation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"dependencies": {
"@graphql-tools/batch-delegate": "workspace:^",
"@graphql-tools/delegate": "workspace:^",
"@graphql-tools/executor": "^1.4.7",
"@graphql-tools/executor-http": "workspace:^",
Expand All @@ -51,6 +52,7 @@
"@whatwg-node/events": "^0.1.2",
"@whatwg-node/fetch": "^0.10.8",
"@whatwg-node/promise-helpers": "^1.3.0",
"graphql-relay": "^0.10.2",
"tslib": "^2.8.1"
},
"devDependencies": {
Expand Down
Loading
Loading