diff --git a/src/HotChocolate/PersistedOperations/src/PersistedOperations.AzureBlobStorage/Extensions/HotChocolateAzureBlobStoragePersistedOperationsRequestExecutorBuilderExtensions.cs b/src/HotChocolate/PersistedOperations/src/PersistedOperations.AzureBlobStorage/Extensions/HotChocolateAzureBlobStoragePersistedOperationsRequestExecutorBuilderExtensions.cs index 04968342032..b99b9c556d5 100644 --- a/src/HotChocolate/PersistedOperations/src/PersistedOperations.AzureBlobStorage/Extensions/HotChocolateAzureBlobStoragePersistedOperationsRequestExecutorBuilderExtensions.cs +++ b/src/HotChocolate/PersistedOperations/src/PersistedOperations.AzureBlobStorage/Extensions/HotChocolateAzureBlobStoragePersistedOperationsRequestExecutorBuilderExtensions.cs @@ -19,19 +19,22 @@ public static class HotChocolateAzureBlobStoragePersistedOperationsRequestExecut /// A factory that resolves the Azure Blob Container Client that /// shall be used for persistence. /// - /// This prefix string is prepended before the hash of the document. - /// This suffix is appended after the hash of the document. public static IRequestExecutorBuilder AddAzureBlobStorageOperationDocumentStorage( this IRequestExecutorBuilder builder, - Func containerClientFactory, - string blobNamePrefix = "", - string blobNameSuffix = ".graphql") + Func containerClientFactory) { - ArgumentNullException.ThrowIfNull(builder); - ArgumentNullException.ThrowIfNull(containerClientFactory); + if(builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if(containerClientFactory is null) + { + throw new ArgumentNullException(nameof(containerClientFactory)); + } return builder.ConfigureSchemaServices( s => s.AddAzureBlobStorageOperationDocumentStorage( - sp => containerClientFactory(sp.GetCombinedServices()), blobNamePrefix, blobNameSuffix)); + sp => containerClientFactory(sp.GetCombinedServices()))); } } diff --git a/src/HotChocolate/PersistedOperations/src/PersistedOperations.AzureBlobStorage/Extensions/HotChocolateAzureBlobStoragePersistedOperationsServiceCollectionExtensions.cs b/src/HotChocolate/PersistedOperations/src/PersistedOperations.AzureBlobStorage/Extensions/HotChocolateAzureBlobStoragePersistedOperationsServiceCollectionExtensions.cs index 6b8cfc029a2..67c1fb8a9d9 100644 --- a/src/HotChocolate/PersistedOperations/src/PersistedOperations.AzureBlobStorage/Extensions/HotChocolateAzureBlobStoragePersistedOperationsServiceCollectionExtensions.cs +++ b/src/HotChocolate/PersistedOperations/src/PersistedOperations.AzureBlobStorage/Extensions/HotChocolateAzureBlobStoragePersistedOperationsServiceCollectionExtensions.cs @@ -6,7 +6,7 @@ namespace HotChocolate; /// -/// Provides utility methods to setup dependency injection. +/// Provides utility methods to set up dependency injection. /// public static class HotChocolateAzureBlobStoragePersistedOperationsServiceCollectionExtensions { @@ -20,22 +20,24 @@ public static class HotChocolateAzureBlobStoragePersistedOperationsServiceCollec /// A factory that resolves the Azure Blob Container Client that /// shall be used for persistence. /// - /// This prefix string is prepended before the hash of the document. - /// This suffix is appended after the hash of the document. public static IServiceCollection AddAzureBlobStorageOperationDocumentStorage( this IServiceCollection services, - Func containerClientFactory, - string blobNamePrefix = "", - string blobNameSuffix = ".graphql" - ) + Func containerClientFactory) { - ArgumentNullException.ThrowIfNull(services); - ArgumentNullException.ThrowIfNull(containerClientFactory); + if(services == null) + { + throw new ArgumentNullException(nameof(services)); + } + + if(containerClientFactory == null) + { + throw new ArgumentNullException(nameof(containerClientFactory)); + } return services .RemoveService() .AddSingleton( - sp => new AzureBlobOperationDocumentStorage(containerClientFactory(sp), blobNamePrefix, blobNameSuffix)); + sp => new AzureBlobOperationDocumentStorage(containerClientFactory(sp))); } private static IServiceCollection RemoveService( diff --git a/src/HotChocolate/PersistedOperations/test/PersistedOperations.AzureBlobStorage.Tests/AzureBlobStorageOperationDocumentStorageTests.cs b/src/HotChocolate/PersistedOperations/test/PersistedOperations.AzureBlobStorage.Tests/AzureBlobStorageOperationDocumentStorageTests.cs index 15015f99de9..ff2e929816f 100644 --- a/src/HotChocolate/PersistedOperations/test/PersistedOperations.AzureBlobStorage.Tests/AzureBlobStorageOperationDocumentStorageTests.cs +++ b/src/HotChocolate/PersistedOperations/test/PersistedOperations.AzureBlobStorage.Tests/AzureBlobStorageOperationDocumentStorageTests.cs @@ -9,8 +9,6 @@ namespace HotChocolate.PersistedOperations.AzureBlobStorage; public class AzureBlobStorageOperationDocumentStorageTests : IClassFixture { private readonly BlobContainerClient _client; - private const string Prefix = "hc_"; - private const string Suffix = ".graphql"; public AzureBlobStorageOperationDocumentStorageTests(AzureStorageBlobResource blobStorageResource) { @@ -23,7 +21,7 @@ public async Task Write_OperationDocument_To_Storage() { // arrange var documentId = new OperationDocumentId(Guid.NewGuid().ToString("N")); - var storage = new AzureBlobOperationDocumentStorage(_client, Prefix, Suffix); + var storage = new AzureBlobOperationDocumentStorage(_client); var document = new OperationDocumentSourceText("{ foo }"); // act @@ -41,21 +39,21 @@ public async Task Write_OperationDocument_documentId_Invalid() { // arrange var documentId = new OperationDocumentId(); - var storage = new AzureBlobOperationDocumentStorage(_client, Prefix, Suffix); + var storage = new AzureBlobOperationDocumentStorage(_client); var document = new OperationDocumentSourceText("{ foo }"); // act async Task Action() => await storage.SaveAsync(documentId, document); // assert - await Assert.ThrowsAsync(Action); + await Assert.ThrowsAsync(Action); } [Fact] public async Task Write_OperationDocument_OperationDocument_Is_Null() { // arrange - var storage = new AzureBlobOperationDocumentStorage(_client, Prefix, Suffix); + var storage = new AzureBlobOperationDocumentStorage(_client); var documentId = new OperationDocumentId(Guid.NewGuid().ToString("N")); // act @@ -70,7 +68,7 @@ public async Task Read_OperationDocument_From_Storage() { // arrange var documentId = new OperationDocumentId(Guid.NewGuid().ToString("N")); - var storage = new AzureBlobOperationDocumentStorage(_client, Prefix, Suffix); + var storage = new AzureBlobOperationDocumentStorage(_client); var buffer = "{ foo }"u8.ToArray(); await WriteBlob(documentId.Value, buffer); @@ -89,7 +87,7 @@ public async Task Read_OperationDocument_documentId_Invalid() { // arrange var documentId = new OperationDocumentId(); - var storage = new AzureBlobOperationDocumentStorage(_client, Prefix, Suffix); + var storage = new AzureBlobOperationDocumentStorage(_client); // act async Task Action() => await storage.TryReadAsync(documentId); @@ -116,5 +114,5 @@ private async Task WriteBlob(string key, byte[] buffer) private async Task DeleteBlob(string key) => await _client.DeleteBlobAsync(BlobName(key)); - private static string BlobName(string key) => $"{Prefix}{key}{Suffix}"; + private static string BlobName(string key) => $"{key}"; } diff --git a/src/HotChocolate/PersistedOperations/test/PersistedOperations.AzureBlobStorage.Tests/IntegrationTests.cs b/src/HotChocolate/PersistedOperations/test/PersistedOperations.AzureBlobStorage.Tests/IntegrationTests.cs index 8199361e1f2..e18e145f6ab 100644 --- a/src/HotChocolate/PersistedOperations/test/PersistedOperations.AzureBlobStorage.Tests/IntegrationTests.cs +++ b/src/HotChocolate/PersistedOperations/test/PersistedOperations.AzureBlobStorage.Tests/IntegrationTests.cs @@ -8,9 +8,6 @@ namespace HotChocolate.PersistedOperations.AzureBlobStorage; public class IntegrationTests : IClassFixture { - private const string Prefix = "hc_"; - private const string Suffix = ".graphql"; - private readonly BlobContainerClient _client; public IntegrationTests(AzureStorageBlobResource blobStorageResource) @@ -24,7 +21,7 @@ public async Task ExecutePersistedOperation() { // arrange var documentId = new OperationDocumentId(Guid.NewGuid().ToString("N")); - var storage = new AzureBlobOperationDocumentStorage(_client, Prefix, Suffix); + var storage = new AzureBlobOperationDocumentStorage(_client); await storage.SaveAsync( documentId, @@ -34,7 +31,7 @@ await storage.SaveAsync( await new ServiceCollection() .AddGraphQL() .AddQueryType(c => c.Name("Query").Field("a").Resolve("b")) - .AddAzureBlobStorageOperationDocumentStorage(_ => _client, Prefix, Suffix) + .AddAzureBlobStorageOperationDocumentStorage(_ => _client) .UseRequest(n => async c => { await n(c); @@ -62,14 +59,14 @@ public async Task ExecutePersistedOperation_NotFound() { // arrange var documentId = new OperationDocumentId(Guid.NewGuid().ToString("N")); - var storage = new AzureBlobOperationDocumentStorage(_client, Prefix, Suffix); + var storage = new AzureBlobOperationDocumentStorage(_client); await storage.SaveAsync(documentId, new OperationDocumentSourceText("{ __typename }")); var executor = await new ServiceCollection() .AddGraphQL() .AddQueryType(c => c.Name("Query").Field("a").Resolve("b")) - .AddAzureBlobStorageOperationDocumentStorage(_ => _client, Prefix, Suffix) + .AddAzureBlobStorageOperationDocumentStorage(_ => _client) .UseRequest(n => async c => { await n(c);