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 256
256
<Compile Include =" Types\ConnectionExtensions.cs" />
257
257
<Compile Include =" Types\ConnectionWithFilterBuilder.cs" />
258
258
<Compile Include =" Types\PublishedContentAtRootQuery.cs" />
259
+ <Compile Include =" Types\PublishedContentByTypeQuery.cs" />
259
260
<Compile Include =" Types\PublishedContentQuery.cs" />
260
261
<Compile Include =" Web\AppBuilderExtensions.cs" />
261
262
<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)
19
19
return userContext . Umbraco . TypedContent ( id ) ;
20
20
} ) ;
21
21
22
+ Field < NonNullGraphType < PublishedContentAtRootQuery > > ( )
23
+ . Name ( "byType" )
24
+ . Resolve ( context => context . ReturnType )
25
+ . Type ( new NonNullGraphType ( new PublishedContentByTypeQuery ( documentGraphTypes ) ) ) ;
26
+
22
27
Field < NonNullGraphType < PublishedContentAtRootQuery > > ( )
23
28
. Name ( "atRoot" )
24
29
. Resolve ( context => context . ReturnType )
You can’t perform that action at this time.
0 commit comments