Skip to content

Commit 169d9c8

Browse files
author
github-actions
committed
Documentation update
1 parent 453bc66 commit 169d9c8

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

docs/migrations/migration8/index.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,33 @@ <h3 id="28-code-classlanguage-textiresolvefieldcontextexecutioncontextcode-prope
10241024
<p>The <code class="language-text">ExecutionContext</code> property has been added to the <code class="language-text">IResolveFieldContext</code> interface to allow access to the
10251025
underlying execution context. This is useful for accessing the parsed arguments and directives from the operation
10261026
via <code class="language-text">IExecutionContext.GetArguments</code> and <code class="language-text">GetDirectives</code>.</p>
1027+
<h3 id="29-code-classlanguage-textdefaultastvaluecode-attribute-added-v81-and-newer-to-set-default-values-for-complex-types-with-type-first-schemas" style="position:relative;"><a href="#29-code-classlanguage-textdefaultastvaluecode-attribute-added-v81-and-newer-to-set-default-values-for-complex-types-with-type-first-schemas" aria-label="29 code classlanguage textdefaultastvaluecode attribute added v81 and newer to set default values for complex types with type first schemas 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>29. <code class="language-text">[DefaultAstValue]</code> attribute added (v8.1 and newer) to set default values for complex types with type-first schemas</h3>
1028+
<p>When defining an input object or output field argument in a type-first schema, you may now use the <code class="language-text">[DefaultAstValue]</code>
1029+
attribute to specify a default value for the argument. This is useful when the argument is a complex type that cannot
1030+
be represented as a constant via <code class="language-text">[DefaultValue]</code> or in the method signature.</p>
1031+
<div class="gatsby-highlight" data-language="csharp"><pre class="language-csharp"><code class="language-csharp"><span class="token comment">// typical way to set a default value of an input field, which is not possible for complex types</span>
1032+
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">MyInputObject1</span>
1033+
<span class="token punctuation">{</span>
1034+
<span class="token punctuation">[</span><span class="token attribute"><span class="token class-name">DefaultValue</span><span class="token attribute-arguments"><span class="token punctuation">(</span><span class="token string">"value"</span><span class="token punctuation">)</span></span></span><span class="token punctuation">]</span>
1035+
<span class="token keyword">public</span> required <span class="token return-type class-name"><span class="token keyword">string</span></span> Field1 <span class="token punctuation">{</span> <span class="token keyword">get</span><span class="token punctuation">;</span> <span class="token keyword">set</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
1036+
<span class="token punctuation">}</span>
1037+
1038+
<span class="token comment">// demonstrates setting a default value for an input field that has a complex type</span>
1039+
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">MyInputObject2</span>
1040+
<span class="token punctuation">{</span>
1041+
<span class="token punctuation">[</span><span class="token attribute"><span class="token class-name">DefaultAstValue</span><span class="token attribute-arguments"><span class="token punctuation">(</span><span class="token string">"{ field1: \"value\" }"</span><span class="token punctuation">)</span></span></span><span class="token punctuation">]</span>
1042+
<span class="token keyword">public</span> <span class="token return-type class-name">MyInputObject1</span> Json <span class="token punctuation">{</span> <span class="token keyword">get</span><span class="token punctuation">;</span> <span class="token keyword">set</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
1043+
<span class="token punctuation">}</span>
1044+
1045+
<span class="token comment">// output type</span>
1046+
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">MyOutputObject</span>
1047+
<span class="token punctuation">{</span>
1048+
<span class="token comment">// typical way to set a default value of an output field argument</span>
1049+
<span class="token keyword">public</span> <span class="token return-type class-name"><span class="token keyword">string</span></span> <span class="token function">Field1</span><span class="token punctuation">(</span><span class="token class-name"><span class="token keyword">string</span></span> arg <span class="token operator">=</span> <span class="token string">"abc"</span><span class="token punctuation">)</span> <span class="token operator">=></span> arg<span class="token punctuation">;</span>
1050+
1051+
<span class="token comment">// demonstrates setting a default value for an output field argument that has a complex type</span>
1052+
<span class="token keyword">public</span> <span class="token return-type class-name"><span class="token keyword">string</span></span> <span class="token function">Field2</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token attribute"><span class="token class-name">DefaultAstValue</span><span class="token attribute-arguments"><span class="token punctuation">(</span><span class="token string">"{ field1: \"sample2\" }"</span><span class="token punctuation">)</span></span></span><span class="token punctuation">]</span> <span class="token class-name">MyInputObject1</span> arg<span class="token punctuation">)</span> <span class="token operator">=></span> arg<span class="token punctuation">.</span>Field1<span class="token punctuation">;</span>
1053+
<span class="token punctuation">}</span></code></pre></div>
10271054
<h2 id="breaking-changes" style="position:relative;"><a href="#breaking-changes" aria-label="breaking changes 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>Breaking Changes</h2>
10281055
<h3 id="1-query-type-is-required" style="position:relative;"><a href="#1-query-type-is-required" aria-label="1 query type is required 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>1. Query type is required</h3>
10291056
<p>Pursuant to the GraphQL specification, a query type is required for any schema.

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)