@theguild/federation-composition 0.21.2 → 0.21.3-alpha-20260116111315-b788100ad36f46d0bb0081ee852915930ab0d600

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,16 @@ function ensureAccessToSelectionSet(supergraph, currentType, selectionSet, provi
30
30
  switch (selection.kind) {
31
31
  case graphql_1.Kind.FIELD: {
32
32
  if (currentType.kind === "union") {
33
- throw new Error("Cannot select fields directly on union types.");
33
+ if (selection.name.value !== "__typename") {
34
+ throw new Error("Cannot select fields directly on union types.");
35
+ }
36
+ for (const memberTypeName of currentType.members) {
37
+ const memberType = supergraph.objectTypes.get(memberTypeName);
38
+ if (memberType && !provisionedAccess.canAccess(memberType)) {
39
+ return memberTypeName;
40
+ }
41
+ }
42
+ return;
34
43
  }
35
44
  const fieldLackingAccess = ensureAccessToField(supergraph, currentType, selection, provisionedAccess);
36
45
  if (fieldLackingAccess) {
@@ -27,7 +27,16 @@ function ensureAccessToSelectionSet(supergraph, currentType, selectionSet, provi
27
27
  switch (selection.kind) {
28
28
  case Kind.FIELD: {
29
29
  if (currentType.kind === "union") {
30
- throw new Error("Cannot select fields directly on union types.");
30
+ if (selection.name.value !== "__typename") {
31
+ throw new Error("Cannot select fields directly on union types.");
32
+ }
33
+ for (const memberTypeName of currentType.members) {
34
+ const memberType = supergraph.objectTypes.get(memberTypeName);
35
+ if (memberType && !provisionedAccess.canAccess(memberType)) {
36
+ return memberTypeName;
37
+ }
38
+ }
39
+ return;
31
40
  }
32
41
  const fieldLackingAccess = ensureAccessToField(supergraph, currentType, selection, provisionedAccess);
33
42
  if (fieldLackingAccess) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theguild/federation-composition",
3
- "version": "0.21.2",
3
+ "version": "0.21.3-alpha-20260116111315-b788100ad36f46d0bb0081ee852915930ab0d600",
4
4
  "description": "Open Source Composition library for Apollo Federation",
5
5
  "peerDependencies": {
6
6
  "graphql": "^16.0.0"