diff --git a/docker-compose.yml b/docker-compose.yml index dfde248..22bc12d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: POSTGRES_USER: trax POSTGRES_PASSWORD: trax123 POSTGRES_DB: trax - POSTGRES_MULTIPLE_DATABASES: trax_scheduler_tests,trax_data_tests,trax_e2e_tests,chat_e2e_tests,energyhub_e2e_tests,jobhunt,jobhunt_e2e_tests + POSTGRES_MULTIPLE_DATABASES: trax_scheduler_tests,trax_data_tests,trax_e2e_tests,chat_e2e_tests,energyhub_e2e_tests,jobhunt,jobhunt_e2e_tests,trax_api_operations,trax_api_workqueue,trax_api_logs,trax_api_health,trax_api_auth_http,trax_api_auth_model,trax_api_auth_sub,trax_api_auth_subprop,trax_api_auth_authorize tty: true ports: - "5432:5432" diff --git a/samples/PersistedOperations/Trax.Samples.PersistedOperations.Client/Program.cs b/samples/PersistedOperations/Trax.Samples.PersistedOperations.Client/Program.cs index 85cb62f..d197ed9 100644 --- a/samples/PersistedOperations/Trax.Samples.PersistedOperations.Client/Program.cs +++ b/samples/PersistedOperations/Trax.Samples.PersistedOperations.Client/Program.cs @@ -40,17 +40,33 @@ await PostByIdAsync(http, "lookupUser_v1", new { input = new { userId = "user-42" } }) ); -// 4. Hot-fix demo: rewrite greet_v1 with a shape-preserving change. +// 4. Hot-fix demo: rewrite greet_v1 with a GENUINELY different document +// that produces a visibly different response. The new document adds an +// extra `__typename` field inside the greet selection, which changes +// the response shape, so BypassShapeDiff is required. Before the +// invalidation fix in Trax.Api.GraphQL.PersistedOperations, the +// HotChocolate request pipeline kept serving the previous compiled +// operation until the process restarted; with the fix in place the +// next request runs the new document. await UploadAsync( http, "greet_v1", - "query Greet($input: GreetInput!) { discover { greeting { greet(input: $input) { greeting greetedAt } } } }", - description: "demo hot-fix (shape-preserving rewrite)" + "query Greet($input: GreetInput!) { discover { greeting { greet(input: $input) { greeting greetedAt __typename } } } }", + description: "demo hot-fix (adds __typename)", + bypassShapeDiff: true ); Console.WriteLine("\nHot-fixed greet_v1 (no client redeploy needed)."); Console.WriteLine("\n--- greet_v1 after hot-fix (Alice) ---"); -Console.WriteLine(await PostByIdAsync(http, "greet_v1", new { input = new { name = "Alice" } })); +var afterHotFix = await PostByIdAsync(http, "greet_v1", new { input = new { name = "Alice" } }); +Console.WriteLine(afterHotFix); +if (!afterHotFix.Contains("__typename")) + throw new InvalidOperationException( + "Hot-fix did not take effect: response is missing __typename. " + + "This indicates HotChocolate's IDocumentCache / IPreparedOperationCache " + + "were not invalidated when the persisted operation was upserted." + ); +Console.WriteLine("Hot-fix verified: __typename present in response."); static async Task PostByIdAsync(HttpClient http, string id, object variables) {