Skip to content

Commit

Permalink
edits
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib committed Dec 15, 2023
1 parent 1ce4881 commit 85fbd2d
Show file tree
Hide file tree
Showing 2 changed files with 171 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/HotChocolate/Fusion/test/Composition.Tests/TagTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,27 @@ public async Task Exclude_Type_System_Members_With_Internal_Tag()
.FormatAsString(fusionConfig)
.MatchSnapshot(extension: ".graphql");
}

[Fact]
public async Task Exclude_Type_System_Members_With_Internal_Tag_Which_Is_Private()
{
// arrange
using var demoProject = await DemoProject.CreateAsync();

var composer = new FusionGraphComposer(logFactory: _logFactory);

var fusionConfig = await composer.ComposeAsync(
new[]
{
demoProject.Accounts.ToConfiguration(AccountsExtensionWithTagSdl),
demoProject.Reviews.ToConfiguration(ReviewsExtensionWithTagSdl),
},
new FusionFeatureCollection(FusionFeatures.TagDirective(
makeTagsPublic: false,
exclude: new[] {"internal"})));

SchemaFormatter
.FormatAsString(fusionConfig)
.MatchSnapshot(extension: ".graphql");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
schema
@fusion(version: 1)
@transport(subgraph: "Accounts", location: "http:\/\/localhost:5000\/graphql", kind: "HTTP")
@transport(subgraph: "Accounts", location: "ws:\/\/localhost:5000\/graphql", kind: "WebSocket")
@transport(subgraph: "Reviews", location: "http:\/\/localhost:5000\/graphql", kind: "HTTP")
@transport(subgraph: "Reviews", location: "ws:\/\/localhost:5000\/graphql", kind: "WebSocket") {
query: Query
mutation: Mutation
subscription: Subscription
}

type Query {
productById(id: ID!): Product
@variable(subgraph: "Reviews", name: "id", argument: "id")
@resolver(subgraph: "Reviews", select: "{ productById(id: $id) }", arguments: [ { name: "id", type: "ID!" } ])
reviewById(id: ID!): Review
@variable(subgraph: "Reviews", name: "id", argument: "id")
@resolver(subgraph: "Reviews", select: "{ reviewById(id: $id) }", arguments: [ { name: "id", type: "ID!" } ])
reviewOrAuthor: ReviewOrAuthor!
@resolver(subgraph: "Reviews", select: "{ reviewOrAuthor }")
reviews: [Review!]!
@resolver(subgraph: "Reviews", select: "{ reviews }")
someTypeById(id: ID!): SomeType!
@variable(subgraph: "Accounts", name: "id", argument: "id")
@resolver(subgraph: "Accounts", select: "{ someTypeById(id: $id) }", arguments: [ { name: "id", type: "ID!" } ])
userById(id: ID!): User
@variable(subgraph: "Accounts", name: "id", argument: "id")
@resolver(subgraph: "Accounts", select: "{ userById(id: $id) }", arguments: [ { name: "id", type: "ID!" } ])
@variable(subgraph: "Reviews", name: "id", argument: "id")
@resolver(subgraph: "Reviews", select: "{ authorById(id: $id) }", arguments: [ { name: "id", type: "ID!" } ])
users: [User!]!
@resolver(subgraph: "Accounts", select: "{ users }")
usersById(ids: [ID!]!): [User!]!
@variable(subgraph: "Accounts", name: "ids", argument: "ids")
@resolver(subgraph: "Accounts", select: "{ usersById(ids: $ids) }", arguments: [ { name: "ids", type: "[ID!]!" } ])
viewer: Viewer!
@resolver(subgraph: "Accounts", select: "{ viewer }")
}

type Mutation {
addReview(input: AddReviewInput!): AddReviewPayload!
@variable(subgraph: "Reviews", name: "input", argument: "input")
@resolver(subgraph: "Reviews", select: "{ addReview(input: $input) }", arguments: [ { name: "input", type: "AddReviewInput!" } ])
addUser(input: AddUserInput!): AddUserPayload!
@variable(subgraph: "Accounts", name: "input", argument: "input")
@resolver(subgraph: "Accounts", select: "{ addUser(input: $input) }", arguments: [ { name: "input", type: "AddUserInput!" } ])
}

type Subscription {
onNewReview: Review!
@resolver(subgraph: "Reviews", select: "{ onNewReview }", kind: "SUBSCRIBE")
}

type AddReviewPayload {
review: Review
@source(subgraph: "Reviews")
}

type AddUserPayload {
user: User
@source(subgraph: "Accounts")
}

type Product
@variable(subgraph: "Reviews", name: "Product_id", select: "id")
@resolver(subgraph: "Reviews", select: "{ productById(id: $Product_id) }", arguments: [ { name: "Product_id", type: "ID!" } ]) {
id: ID!
@source(subgraph: "Reviews")
reviews: [Review!]!
@source(subgraph: "Reviews")
}

type Review implements Node
@variable(subgraph: "Reviews", name: "Review_id", select: "id")
@resolver(subgraph: "Reviews", select: "{ reviewById(id: $Review_id) }", arguments: [ { name: "Review_id", type: "ID!" } ])
@resolver(subgraph: "Reviews", select: "{ nodes(ids: $Review_id) { ... on Review { ... Review } } }", arguments: [ { name: "Review_id", type: "[ID!]!" } ], kind: "BATCH") {
author: User!
@source(subgraph: "Reviews")
body: String!
@source(subgraph: "Reviews")
id: ID!
@source(subgraph: "Reviews")
product: Product!
@source(subgraph: "Reviews")
}

type SomeData {
accountValue: String!
@source(subgraph: "Accounts")
}

type SomeType
@variable(subgraph: "Accounts", name: "SomeType_id", select: "id")
@resolver(subgraph: "Accounts", select: "{ someTypeById(id: $SomeType_id) }", arguments: [ { name: "SomeType_id", type: "ID!" } ]) {
id: ID!
@source(subgraph: "Accounts")
}

type User implements Node
@source(subgraph: "Reviews", name: "Author")
@variable(subgraph: "Accounts", name: "User_id", select: "id")
@variable(subgraph: "Reviews", name: "User_id", select: "id")
@resolver(subgraph: "Accounts", select: "{ userById(id: $User_id) }", arguments: [ { name: "User_id", type: "ID!" } ])
@resolver(subgraph: "Accounts", select: "{ usersById(ids: $User_id) }", arguments: [ { name: "User_id", type: "[ID!]!" } ], kind: "BATCH")
@resolver(subgraph: "Reviews", select: "{ authorById(id: $User_id) }", arguments: [ { name: "User_id", type: "ID!" } ])
@resolver(subgraph: "Reviews", select: "{ nodes(ids: $User_id) { ... on User { ... User } } }", arguments: [ { name: "User_id", type: "[ID!]!" } ], kind: "BATCH") {
birthdate: Date!
@source(subgraph: "Accounts")
id: ID!
@source(subgraph: "Accounts")
@source(subgraph: "Reviews")
name: String!
@source(subgraph: "Accounts")
@source(subgraph: "Reviews")
reviews: [Review!]!
@source(subgraph: "Reviews")
username: String!
@source(subgraph: "Accounts")
}

type Viewer {
data: SomeData!
@source(subgraph: "Accounts")
user: User
@source(subgraph: "Accounts")
}

"The node interface is implemented by entities that have a global unique identifier."
interface Node {
id: ID!
}

union ReviewOrAuthor = User | Review

input AddReviewInput {
authorId: Int!
body: String!
upc: Int!
}

input AddUserInput {
birthdate: Date!
name: String!
username: String!
}

"The `Date` scalar represents an ISO-8601 compliant date type."
scalar Date

0 comments on commit 85fbd2d

Please sign in to comment.