You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constructor an instance of <codeclass="language-text">IErrorInfoProvider</code> (see <ahref="#error-serialization">Error Serialization</a> below).
167
167
The converter can be registered within an instance of <codeclass="language-text">JsonSerializerOptions</code> so that serializing an
168
168
<codeclass="language-text">ExecutionResult</code> produces the proper output.</p>
169
-
<p>To assist, a <codeclass="language-text">DocumentWriter</code> class is provided with a single method, <codeclass="language-text">WriteAsync</code>, which
170
-
handles constructing the options, registering the converter, and serializing a specified
171
-
<codeclass="language-text">ExecutionResult</code> to a data stream. This class is designed to be registered as a singleton
169
+
<p>GraphQL.NET provides two interfaces for serialization:</p>
170
+
<ul>
171
+
<li><codeclass="language-text">IGraphQLSerializer</code> - For serializing to/from streams</li>
172
+
<li><codeclass="language-text">IGraphQLTextSerializer</code> - Extends <codeclass="language-text">IGraphQLSerializer</code> with methods for serializing to/from strings</li>
173
+
</ul>
174
+
<p>These interfaces are implemented by the <codeclass="language-text">GraphQLSerializer</code> class in the <codeclass="language-text">GraphQL.SystemTextJson</code> package and
175
+
a similar class in the <codeclass="language-text">GraphQL.NewtonsoftJson</code> package. These classes are designed to be registered as singletons
172
176
within your dependency injection framework, if applicable.</p>
173
177
<divclass="gatsby-highlight" data-language="csharp"><preclass="language-csharp"><codeclass="language-csharp"><spanclass="token comment">// Manually construct an instance</span>
<p>Here is an example of the <codeclass="language-text">DocumentWriter</code>'s use within the <codeclass="language-text">Harness</code> sample project:</p>
<p>The GraphQL spec allows for four properties to be returned within each
190
-
error: <codeclass="language-text">message</code>, <codeclass="language-text">locations</code>, <codeclass="language-text">path</code>, and <codeclass="language-text">extensions</code>. The <codeclass="language-text">IDocumentWriter</code> implementations
194
+
error: <codeclass="language-text">message</code>, <codeclass="language-text">locations</code>, <codeclass="language-text">path</code>, and <codeclass="language-text">extensions</code>. The <codeclass="language-text">IGraphQLSerializer</code> implementations
191
195
provided for the <ahref="https://www.nuget.org/packages/GraphQL.NewtonsoftJson"><codeclass="language-text">Newtonsoft.Json</code></a> and
192
196
<ahref="https://www.nuget.org/packages/GraphQL.SystemTextJson"><codeclass="language-text">System.Text.Json</code></a> packages allow you to control the
193
197
serialization of <codeclass="language-text">ExecutionError</code>s into the resulting json data by providing an <codeclass="language-text">IErrorInfoProvider</code>
194
-
to the constructor of the document writer. The <codeclass="language-text">ErrorInfoProvider</code> class (default implementation of
198
+
to the constructor of the serializer. The <codeclass="language-text">ErrorInfoProvider</code> class (default implementation of
195
199
<codeclass="language-text">IErrorInfoProvider</code>) contains 5 properties to control serialization behavior:</p>
196
200
<ul>
197
201
<li><codeclass="language-text">ExposeExceptionStackTrace</code> when enabled sets the <codeclass="language-text">message</code> property for errors to equal the</li>
0 commit comments