Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib committed Jan 2, 2025
1 parent 731ad09 commit 1af5c8f
Showing 1 changed file with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,50 @@ type Query

var product = schema.GetType<CompositeObjectType>("Product");
Assert.Equal("Product", product.Name);
Assert.Equal("ACCOUNTS", Assert.Single(node.Sources).SchemaName);
Assert.Equal("node", Assert.Single(node.Implements).Name);
Assert.Equal("ACCOUNTS", Assert.Single(product.Sources).SchemaName);
Assert.Equal("Node", Assert.Single(product.Implements).Name);
}

[Fact]
public void Interface_With_Lookup()
{
var schema = CreateCompositeSchema(
"""
interface Node
@fusion__type(schema: ACCOUNTS)
@fusion__lookup(
schema: ACCOUNTS
key: "{ id }"
field: "node(id: ID!): Node"
map: ["id"]
) {
id: ID!
@fusion__field(schema: ACCOUNTS)
}
type Product implements Node
@fusion__type(schema: ACCOUNTS)
@fusion__lookup(
schema: ACCOUNTS
key: "{ id }"
field: "node(id: ID!): Node"
map: ["id"]
) {
id: ID!
@fusion__field(schema: ACCOUNTS)
name: String
@fusion__field(schema: ACCOUNTS)
}
type Query
@fusion__type(schema: ACCOUNTS) {
node(id: ID!): Node
}
""");

var node = schema.GetType<CompositeInterfaceType>("Node");
var id = Assert.Single(Assert.Single(node.Sources).Lookups).Fields.Single().ToString();
Assert.Equal("id", id);
}

}

0 comments on commit 1af5c8f

Please sign in to comment.