Skip to content

Commit

Permalink
Add more things to union-intersection case (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkisiela authored Apr 24, 2024
1 parent b7712a2 commit 697553c
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/test-cases/union-intersection/a.subgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,32 @@ export default createSubgraph("a", {
import: ["@shareable"]
)
union Media = Book
union Media = Book | Song
type Book {
title: String! @shareable
}
type Song {
title: String! @shareable
}
type Query {
media: Media @shareable
book: Book @shareable
song: Media @shareable
}
`,
resolvers: {
Query: {
media: () => media,
book: () => media,
song: () => {
return {
__typename: "Song",
title: "Song Title",
};
},
},
},
});
2 changes: 2 additions & 0 deletions src/test-cases/union-intersection/b.subgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default createSubgraph("b", {
type Query {
media: Media @shareable
book: Media @shareable
}
union Media = Book | Movie
Expand All @@ -26,6 +27,7 @@ export default createSubgraph("b", {
resolvers: {
Query: {
media: () => media,
book: () => media,
},
},
});
58 changes: 58 additions & 0 deletions src/test-cases/union-intersection/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,62 @@ export default [
},
}
),
createTest(
/* GraphQL */ `
query {
media {
__typename
... on Song {
title
}
... on Movie {
title
}
... on Book {
title
}
}
book {
__typename
... on Song {
title
}
... on Movie {
title
}
... on Book {
title
}
}
song {
__typename
... on Song {
title
}
... on Movie {
title
}
... on Book {
title
}
}
}
`,
{
data: {
media: {
__typename: "Book",
title: "The Lord of the Rings",
},
book: {
__typename: "Book",
title: "The Lord of the Rings",
},
song: {
__typename: "Song",
title: "Song Title",
},
},
}
),
];

0 comments on commit 697553c

Please sign in to comment.