@@ -1239,6 +1239,25 @@ <h3 id="34-deprecated-element-detection-and-validation-support-v86" style="posit
12391239 < span class ="token punctuation "> .</ span > < span class ="token generic-method "> < span class ="token function "> AddSchemaVisitor</ span > < span class ="token generic class-name "> < span class ="token punctuation "> <</ span > DeprecatedTypeReferenceVisitor< span class ="token punctuation "> > </ span > </ span > </ span > < span class ="token punctuation "> (</ span > < span class ="token punctuation "> )</ span >
12401240 < span class ="token punctuation "> .</ span > < span class ="token generic-method "> < span class ="token function "> AddValidationRule</ span > < span class ="token generic class-name "> < span class ="token punctuation "> <</ span > LoggingDeprecatedElementsRule< span class ="token punctuation "> > </ span > </ span > </ span > < span class ="token punctuation "> (</ span > < span class ="token punctuation "> )</ span >
12411241< span class ="token punctuation "> )</ span > < span class ="token punctuation "> ;</ span > </ code > </ pre > </ div >
1242+ < h3 id ="35-schema-type-initialization-hooks-v86 " style ="position:relative; "> < a href ="#35-schema-type-initialization-hooks-v86 " aria-label ="35 schema type initialization hooks v86 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 > 35. Schema type initialization hooks (v8.6+)</ h3 >
1243+ < p > A new protected method < code class ="language-text "> OnBeforeInitializeType</ code > has been added to the < code class ="language-text "> Schema</ code > class that is called before each graph type is initialized during schema creation. This allows for custom logic to be executed before type processing, such as logging, validation, or metadata collection.</ p >
1244+ < div class ="gatsby-highlight " data-language ="csharp "> < pre class ="language-csharp "> < code class ="language-csharp "> < span class ="token keyword "> public</ span > < span class ="token keyword "> class</ span > < span class ="token class-name "> MySchema</ span > < span class ="token punctuation "> :</ span > < span class ="token type-list "> < span class ="token class-name "> Schema</ span > </ span >
1245+ < span class ="token punctuation "> {</ span >
1246+ < span class ="token keyword "> public</ span > < span class ="token function "> MySchema</ span > < span class ="token punctuation "> (</ span > < span class ="token class-name "> IServiceProvider</ span > serviceProvider< span class ="token punctuation "> )</ span > < span class ="token punctuation "> :</ span > < span class ="token keyword "> base</ span > < span class ="token punctuation "> (</ span > serviceProvider< span class ="token punctuation "> )</ span >
1247+ < span class ="token punctuation "> {</ span >
1248+ Query < span class ="token operator "> =</ span > < span class ="token keyword "> new</ span > < span class ="token constructor-invocation class-name "> MyQuery</ span > < span class ="token punctuation "> (</ span > < span class ="token punctuation "> )</ span > < span class ="token punctuation "> ;</ span >
1249+ < span class ="token punctuation "> }</ span >
1250+
1251+ < span class ="token keyword "> protected</ 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 "> OnBeforeInitializeType</ span > < span class ="token punctuation "> (</ span > < span class ="token class-name "> IGraphType</ span > graphType< span class ="token punctuation "> )</ span >
1252+ < span class ="token punctuation "> {</ span >
1253+ < span class ="token comment "> // Custom logic before each type is initialized</ span >
1254+ Console< span class ="token punctuation "> .</ span > < span class ="token function "> WriteLine</ span > < span class ="token punctuation "> (</ span > < span class ="token interpolation-string "> < span class ="token string "> $"Initializing type: </ span > < span class ="token interpolation "> < span class ="token punctuation "> {</ span > < span class ="token expression language-csharp "> graphType< span class ="token punctuation "> .</ span > Name</ span > < span class ="token punctuation "> }</ span > </ span > < span class ="token string "> "</ span > </ span > < span class ="token punctuation "> )</ span > < span class ="token punctuation "> ;</ span >
1255+
1256+ < span class ="token comment "> // Example: Add metadata to track initialization order</ span >
1257+ graphType< span class ="token punctuation "> .</ span > < span class ="token function "> WithMetadata</ span > < span class ="token punctuation "> (</ span > < span class ="token string "> "InitializationTimestamp"</ span > < span class ="token punctuation "> ,</ span > DateTime< span class ="token punctuation "> .</ span > UtcNow< span class ="token punctuation "> )</ span > < span class ="token punctuation "> ;</ span >
1258+ < span class ="token punctuation "> }</ span >
1259+ < span class ="token punctuation "> }</ span > </ code > </ pre > </ div >
1260+ < p > This method is called exactly once for each graph type during schema initialization, ensuring that duplicate calls are avoided even when types are referenced multiple times or built automatically.</ p >
12421261< 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 >
12431262< 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 >
12441263< p > Pursuant to the GraphQL specification, a query type is required for any schema.
0 commit comments