Skip to content

Commit

Permalink
fix n+1 query problem, manually specify CollectFields (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
KCarretto authored Nov 6, 2023
1 parent b48a7cc commit c8c4427
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 14 deletions.
56 changes: 42 additions & 14 deletions tavern/internal/graphql/query.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions tavern/test_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ func createTestData(ctx context.Context, client *ent.Client) {
SetOutput(loremIpsum).
SetQuest(printQuest).
SaveX(ctx)

for i := 0; i < 50; i++ {
createQuest(ctx, client, testBeacons...)
}
}

func newRandomIdentifier() string {
Expand Down Expand Up @@ -339,3 +343,30 @@ None
--------
`

func createQuest(ctx context.Context, client *ent.Client, beacons ...*ent.Beacon) {
// Mid-Execution
testTome := client.Tome.Create().
SetName(newRandomIdentifier()).
SetDescription("Print a message for fun!").
SetEldritch(`print(input_params['msg'])`).
SetParamDefs(`[{"name":"msg","label":"Message","type":"string","placeholder":"something to print"}]`).
SaveX(ctx)

q := client.Quest.Create().
SetName(newRandomIdentifier()).
SetParameters(`{"msg":"Hello World!"}`).
SetTome(testTome).
SaveX(ctx)

for _, b := range beacons {
client.Task.Create().
SetBeacon(b).
SetCreatedAt(timeAgo(5 * time.Minute)).
SetClaimedAt(timeAgo(1 * time.Minute)).
SetExecStartedAt(timeAgo(5 * time.Second)).
SetOutput("Hello").
SetQuest(q).
SaveX(ctx)
}
}

0 comments on commit c8c4427

Please sign in to comment.