-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathBaseRootGraph.cs
More file actions
46 lines (39 loc) · 1.41 KB
/
Copy pathBaseRootGraph.cs
File metadata and controls
46 lines (39 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using GraphQL;
using GraphQL.Attachments;
using GraphQL.Types;
public abstract class BaseRootGraph :
ObjectGraphType
{
protected BaseRootGraph()
{
Name = GetType().Name;
Field<ResultGraph>("noAttachment")
.Argument<NonNullGraphType<StringGraphType>>("argument")
.Resolve(context => new Result
{
Argument = context.GetArgument<string>("argument"),
});
#region UsageInGraphs
Field<ResultGraph>("withAttachment")
.Argument<NonNullGraphType<StringGraphType>>("argument")
.Resolve(context =>
{
var incomingAttachments = context.IncomingAttachments();
var outgoingAttachments = context.OutgoingAttachments();
foreach (var incoming in incomingAttachments.Values)
{
// For sample purpose echo the incoming request
// stream to the outgoing response stream
var memoryStream = new MemoryStream();
incoming.CopyTo(memoryStream);
memoryStream.Position = 0;
outgoingAttachments.AddStream(incoming.Name, memoryStream);
}
return new Result
{
Argument = context.GetArgument<string>("argument"),
};
});
#endregion
}
}