File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
src/Our.Umbraco.GraphQL/Types Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,31 @@ public PublishedContentQuery(IEnumerable<IGraphType> documentGraphTypes)
19
19
return userContext . Umbraco . TypedContent ( id ) ;
20
20
} ) ;
21
21
22
+ Field < PublishedContentGraphType > ( )
23
+ . Name ( "byUrl" )
24
+ . Argument < NonNullGraphType < StringGraphType > > ( "url" , "The relative content url" )
25
+ . Resolve ( context =>
26
+ {
27
+ var userContext = context . UmbracoUserContext ( ) ;
28
+ var url = context . GetArgument < string > ( "url" ) ;
29
+
30
+ var pcr = new PublishedContentRequest (
31
+ new Uri ( userContext . RequestUri , url ) ,
32
+ userContext . UmbracoContext . RoutingContext ,
33
+ UmbracoConfig . For . UmbracoSettings ( ) . WebRouting ,
34
+ null
35
+ ) ;
36
+
37
+ pcr . Prepare ( ) ;
38
+
39
+ if ( pcr . IsRedirect || pcr . IsRedirectPermanent || pcr . Is404 )
40
+ {
41
+ return null ;
42
+ }
43
+
44
+ return pcr . PublishedContent ;
45
+ } ) ;
46
+
22
47
Field < NonNullGraphType < PublishedContentAtRootQuery > > ( )
23
48
. Name ( "atRoot" )
24
49
. Resolve ( context => context . ReturnType )
You can’t perform that action at this time.
0 commit comments