File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed
Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 256256 <Compile Include =" Types\ConnectionExtensions.cs" />
257257 <Compile Include =" Types\ConnectionWithFilterBuilder.cs" />
258258 <Compile Include =" Types\PublishedContentAtRootQuery.cs" />
259+ <Compile Include =" Types\PublishedContentByTypeQuery.cs" />
259260 <Compile Include =" Types\PublishedContentQuery.cs" />
260261 <Compile Include =" Web\AppBuilderExtensions.cs" />
261262 <Compile Include =" Web\GraphQLServerOptions.cs" />
Original file line number Diff line number Diff line change 1+ using System . Collections . Generic ;
2+ using GraphQL . Types ;
3+
4+ namespace Our . Umbraco . GraphQL . Types
5+ {
6+ public class PublishedContentByTypeQuery : ObjectGraphType
7+ {
8+ public PublishedContentByTypeQuery ( IEnumerable < IGraphType > documentGraphTypes )
9+ {
10+ Name = "PublishedContentByTypeQuery" ;
11+
12+ foreach ( var type in documentGraphTypes )
13+ {
14+ string documentTypeAlias = type . GetMetadata < string > ( "documentTypeAlias" ) ;
15+
16+ Field < PublishedContentGraphType > ( )
17+ . Name ( type . Name )
18+ . Argument < NonNullGraphType < IdGraphType > > ( "id" , "The unique content id" )
19+ . Type ( type )
20+ . Resolve ( context =>
21+ {
22+ var userContext = ( UmbracoGraphQLContext ) context . UserContext ;
23+ var id = context . GetArgument < int > ( "id" ) ;
24+ return userContext . Umbraco . TypedContent ( id ) ;
25+ } ) ;
26+ }
27+ }
28+ }
29+ }
Original file line number Diff line number Diff line change @@ -19,6 +19,11 @@ public PublishedContentQuery(IEnumerable<IGraphType> documentGraphTypes)
1919 return userContext . Umbraco . TypedContent ( id ) ;
2020 } ) ;
2121
22+ Field < NonNullGraphType < PublishedContentAtRootQuery > > ( )
23+ . Name ( "byType" )
24+ . Resolve ( context => context . ReturnType )
25+ . Type ( new NonNullGraphType ( new PublishedContentByTypeQuery ( documentGraphTypes ) ) ) ;
26+
2227 Field < NonNullGraphType < PublishedContentAtRootQuery > > ( )
2328 . Name ( "atRoot" )
2429 . Resolve ( context => context . ReturnType )
You can’t perform that action at this time.
0 commit comments