Skip to content

Commit

Permalink
Update apollo subgraph compatibility tests
Browse files Browse the repository at this point in the history
  • Loading branch information
angrykoala committed Nov 19, 2024
1 parent 14f2b8c commit ed732e2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 29 deletions.
39 changes: 34 additions & 5 deletions packages/apollo-federation-subgraph-compatibility/src/type-defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,31 @@ export const typeDefs = gql`
id: ID!
sku: String
package: String
variation: ProductVariation @relationship(type: "HAS_VARIATION", direction: OUT)
dimensions: ProductDimension @relationship(type: "HAS_DIMENSIONS", direction: OUT)
createdBy: User @provides(fields: "totalProductsCreated") @relationship(type: "CREATED_BY", direction: OUT)
variation: ProductVariation
@cypher(
statement: """
MATCH (this)-[:HAS_VARIATION]->(res:ProductVariation)
RETURN res
"""
columnName: "res"
)
dimensions: ProductDimension
@cypher(
statement: """
MATCH (this)-[:HAS_DIMENSIONS]->(res:ProductDimension)
RETURN res
"""
columnName: "res"
)
createdBy: User
@provides(fields: "totalProductsCreated")
@cypher(
statement: """
MATCH (this)-[:CREATED_BY]->(res:User)
RETURN res
"""
columnName: "res"
)
notes: String @tag(name: "internal")
research: [ProductResearch!]! @relationship(type: "HAS_RESEARCH", direction: OUT)
}
Expand All @@ -57,15 +79,22 @@ export const typeDefs = gql`
sku: String!
package: String!
reason: String
createdBy: User @relationship(type: "CREATED_BY", direction: OUT)
createdBy: [User!]! @relationship(type: "CREATED_BY", direction: OUT)
}
type ProductVariation {
id: ID!
}
type ProductResearch @key(fields: "study { caseNumber }") {
study: CaseStudy! @relationship(type: "HAS_STUDY", direction: OUT)
study: CaseStudy!
@cypher(
statement: """
MATCH (this)-[:HAS_STUDY]->(res:CaseStudy)
RETURN res
"""
columnName: "res"
)
outcome: String
}
Expand Down
24 changes: 0 additions & 24 deletions packages/graphql/src/schema/validation/validate-document.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,30 +139,6 @@ describe("single relationship deprecation warning", () => {
warn.mockReset();
});

test("deprecated warning triggers on single relationships", () => {
const doc = gql`
type Movie @node {
id: ID
topActor: Actor @relationship(type: "TOP_ACTOR", direction: OUT)
}
type Actor @node {
name: String
}
`;

validateDocument({
document: doc,
additionalDefinitions,
features: {},
});

expect(warn).toHaveBeenCalledWith(
"Using @relationship directive on a non-list element is deprecated and will be removed in next major version."
);
expect(warn).toHaveBeenCalledOnce();
});

test("deprecated warning does not trigger on list relationships", () => {
const doc = gql`
type Movie @node {
Expand Down

0 comments on commit ed732e2

Please sign in to comment.