public static async Task <AttachmentExecutionResult> ExecuteQuery(
        string query,
        ServiceCollection services,
        IIncomingAttachments incomingAttachments)
    {
        query = query.Replace("'", "\"");
        await using var provider = services.BuildServiceProvider();
        using var schema         = new Schema(provider);
        var options = new ExecutionOptions
        {
            Schema = schema,
            Query  = query
        };

        var result = await executer.ExecuteWithAttachments(options, incomingAttachments);

        var executionResult = result.ExecutionResult;

        if (executionResult.Errors == null || !executionResult.Errors.Any())
        {
            return(result);
        }

        if (executionResult.Errors.Count == 1)
        {
            throw executionResult.Errors.First();
        }

        throw new AggregateException(executionResult.Errors);
    }
    async Task Execute(
        string query, string operation,
        IIncomingAttachments incomingAttachments,
        Inputs inputs,
        CancellationToken cancellation)
    {
        var executionOptions = new ExecutionOptions
        {
            Schema            = schema,
            Query             = query,
            OperationName     = operation,
            Inputs            = inputs,
            CancellationToken = cancellation,
#if (DEBUG)
            ThrowOnUnhandledException = true,
            EnableMetrics             = true,
#endif
        };

        #region ExecuteWithAttachments

        var result = await executer.ExecuteWithAttachments(
            executionOptions,
            incomingAttachments);

        #endregion

        #region ResponseWriter

        await ResponseWriter.WriteResult(Response, result, cancellation);

        #endregion
    }
 public AttachmentContext(IIncomingAttachments incoming)
 {
     Guard.AgainstNull(nameof(incoming), incoming);
     Incoming = incoming;
     Outgoing = new OutgoingAttachments();
 }
 public AttachmentContext(IIncomingAttachments incoming)
 {
     Incoming = incoming;
     Outgoing = new OutgoingAttachments();
 }