Skip to content

Commit 2e0118d

Browse files
author
github-actions
committed
Documentation update
1 parent 169d9c8 commit 2e0118d

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

docs/migrations/migration8/index.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,35 @@ <h3 id="29-code-classlanguage-textiresolvefieldcontextexecutioncontextcode-added
14061406
<p>To continue to use the <code class="language-text">ExecutionHelper.GetArguments</code> method, you may need to refer to the GraphQL.NET source
14071407
for reference.</p>
14081408
<p>If you directly implement <code class="language-text">IResolveFieldContext</code>, you must now also implement the <code class="language-text">ExecutionContext</code> property.</p>
1409+
<h3 id="30-code-classlanguage-textgraphtypeinitializecode-method-is-now-called-after-initialization-is-complete" style="position:relative;"><a href="#30-code-classlanguage-textgraphtypeinitializecode-method-is-now-called-after-initialization-is-complete" aria-label="30 code classlanguage textgraphtypeinitializecode method is now called after initialization is complete permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>30. <code class="language-text">GraphType.Initialize</code> method is now called after initialization is complete</h3>
1410+
<p>The <code class="language-text">Initialize</code> method on each <code class="language-text">GraphType</code> is now called after the schema has been fully initialized. As such,
1411+
you cannot add fields to the graph type expecting <code class="language-text">SchemaTypes</code> to resolve types and apply name converters.
1412+
If it is necessary for your graph type to add fields dynamically, you should do so in the constructor or else
1413+
set the <code class="language-text">ResolvedType</code> property for the new fields. Failing to do so will result in a schema validation exception.</p>
1414+
<p>Please note that the constructor is the preferred place to add fields to a graph type.</p>
1415+
<div class="gatsby-highlight" data-language="csharp"><pre class="language-csharp"><code class="language-csharp"><span class="token comment">// v7</span>
1416+
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">MyGraphType</span> <span class="token punctuation">:</span> <span class="token type-list"><span class="token class-name">ObjectGraphType</span></span>
1417+
<span class="token punctuation">{</span>
1418+
<span class="token keyword">public</span> <span class="token keyword">override</span> <span class="token return-type class-name"><span class="token keyword">void</span></span> <span class="token function">Initialize</span><span class="token punctuation">(</span><span class="token class-name">ISchema</span> schema<span class="token punctuation">)</span>
1419+
<span class="token punctuation">{</span>
1420+
<span class="token function">AddField</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token constructor-invocation class-name">FieldType</span> <span class="token punctuation">{</span>
1421+
Name <span class="token operator">=</span> <span class="token string">"Field"</span><span class="token punctuation">,</span>
1422+
Type <span class="token operator">=</span> <span class="token keyword">typeof</span><span class="token punctuation">(</span><span class="token type-expression class-name">StringGraphType</span><span class="token punctuation">)</span>
1423+
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1424+
<span class="token punctuation">}</span>
1425+
<span class="token punctuation">}</span>
1426+
1427+
<span class="token comment">// v8</span>
1428+
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">MyGraphType</span> <span class="token punctuation">:</span> <span class="token type-list"><span class="token class-name">ObjectGraphType</span></span>
1429+
<span class="token punctuation">{</span>
1430+
<span class="token keyword">public</span> <span class="token keyword">override</span> <span class="token return-type class-name"><span class="token keyword">void</span></span> <span class="token function">Initialize</span><span class="token punctuation">(</span><span class="token class-name">ISchema</span> schema<span class="token punctuation">)</span>
1431+
<span class="token punctuation">{</span>
1432+
<span class="token function">AddField</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token constructor-invocation class-name">FieldType</span> <span class="token punctuation">{</span>
1433+
Name <span class="token operator">=</span> <span class="token string">"field"</span><span class="token punctuation">,</span> <span class="token comment">// name converter is not applied here, so the name must be exactly as desired</span>
1434+
ResolvedType <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token constructor-invocation class-name">StringGraphType</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
1435+
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1436+
<span class="token punctuation">}</span>
1437+
<span class="token punctuation">}</span></code></pre></div>
14091438
<h2 id="appendix" style="position:relative;"><a href="#appendix" aria-label="appendix permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Appendix</h2>
14101439
<h3 id="schema-verification-test-example" style="position:relative;"><a href="#schema-verification-test-example" aria-label="schema verification test example permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Schema verification test example</h3>
14111440
<p>The below example demonstrates how to write a test to verify that the schema does not change during

page-data/docs/migrations/migration8/page-data.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)