is GraphQL available on Umbraco 12?
# help-with-umbraco
n
Umbraco 12 headless supports GrpahQL ?
n
s
Yep, recommend ☝️ No GraphQL out of the box on v12 πŸ™‚
n
cool. will give it a go
thanks
@Nikcio getting bellow error when installing this package and run umbraco
An error occurred while starting the application. AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Umbraco.Cms.Core.Events.INotificationAsyncHandler`1[Umbraco.Cms.Core.Notifications.MediaTypeChangedNotification] Lifetime: Transient ImplementationType: Nikcio.UHeadless.Media.NotificationHandlers.MediaTypeModuleMediaTypeChangedHandler': Unable to resolve service for type 'Nikcio.UHeadless.Base.Properties.Maps.IPropertyMap' while attempting to activate 'Nikcio.UHeadless.Media.TypeModules.MediaTypeModule'.) (Error while validating the service descriptor 'ServiceType: Nikcio.UHeadless.Media.TypeModules.MediaTypeModule Lifetime: Singleton ImplementationType: Nikcio.UHeadless.Media.TypeModules.MediaTypeModule': Unable to resolve service for type 'Nikcio.UHeadless.Base.Properties.Maps.IPropertyMap' while attempting to activate 'Nikcio.UHeadless.Media.TypeModules.MediaTypeModule'.) (Error while validating the service descriptor 'ServiceType: Umbraco.Cms.Core.Events.INotificationAsyncHandler`1[Umbraco.Cms.Core.Notifications.ContentTypeChangedNotification] Lifetime: Transient ImplementationType: Nikcio.UHeadless.Content.NotificationHandlers.ContentTypeModuleContentTypeChangedHandler': Unable to resolve service for type 'Nikcio.UHeadless.Base.Properties.Maps.IPropertyMap' while attempting to activate 'Nikcio.UHeadless.Content.TypeModules.ContentTypeModule'.) (Error while validating the service descriptor 'ServiceType: Nikcio.UHeadless.Content.TypeModules.ContentTypeModule Lifetime: Singleton ImplementationType: Nikcio.UHeadless.Content.TypeModules.ContentTypeModule': Unable to resolve service for type 'Nikcio.UHeadless.Base.Properties.Maps.IPropertyMap' while attempting to activate 'Nikcio.UHeadless.Content.TypeModules.ContentTypeModule'.) Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection serviceDescriptors,
n
Try this .AddUHeadless(new() { UHeadlessGraphQLOptions = new() { GraphQLExtensions = (IRequestExecutorBuilder builder) => { builder.UseContentQueries(); // Use this from v4.1.0+ (Only add one) builder.AddTypeExtension(); return builder; }, }, })
It looks like you are missing a call to
builder.UseContentQueries()
Did you add anything to
GraphQLExtensions
or is this pure default?
@Nilay Any luck?
n
Hi @Nikcio , its pure default. I am going to try the solution soon
n
Argh just had a look at the error once more and you'll also need to add
builder.UseMediaQueries();
for it to work. I'll problerly need to push a bug fix. Because that's not how it's supposed to workπŸ˜…
n
its working without IRequestExecutorBuilder
whats reference for the IRequestExecutorBuilder ?
n
IRequestExecutorBuilder
is from HotChocolate which is used to run the underlying GraphQL Server
I've just started publishing v4.1.1 which should fix the issue you experienced.
It happend because I compose on some notification that shouldn't be composed unless explictly told so with a
.UseContentQueries()
or
.UseMediaQueries()
extension πŸ˜…
n
cool. will give it a go and let you know
seems to be working
any documentation to see what fields are available e.g. if use ContentById, what fields are avaialble
n
If you go to /graphql in your application you'll find bannapopcake an explorer for the GraphQL endpoint.
You can also see https://nikcio.github.io/Nikcio.UHeadless/v4/fundamentals/querying/content/ To see what types of queries are available
Just add a query to your UHeadless config and then you can explore the fields in the explorer at /graphql
But basically the fields correspond to the properties in the BasicConent model. If you havn't added a custom model
n
I am making good progress
now here where I am stuck
Here is query for contentByGuid
contentByGuid(id:"6fa7ad54-7c4b-488a-9af7-00f046609b53") { name createDate creatorId urlSegment url absoluteUrl children { path url } namedProperties { __typename } properties { alias value { model } editorAlias } } }
and result
Copy code
{
  "data": {
    "contentByGuid": {
      "name": "Navigation",
      "createDate": "2022-05-18T03:39:36.000+05:30",
      "creatorId": -1,
      "urlSegment": "navigation",
      "url": "/navigation/",
      "absoluteUrl": "https://localhost:44328/navigation/",
      "children": [],
      "namedProperties": {
        "__typename": "DG_Navigation"
      },
      "properties": [
        {
          "alias": "mainNavigation",
          "value": {
            "model": "BasicMultiUrlPicker"
          },
          "editorAlias": "Umbraco.MultiUrlPicker"
        },
        {
          "alias": "displaySubPages",
          "value": {
            "model": "BasicPropertyValue"
          },
          "editorAlias": "Umbraco.TrueFalse"
        },
        {
          "alias": "socialIconHeading",
          "value": {
            "model": "BasicPropertyValue"
          },
          "editorAlias": "Umbraco.TextBox"
        },
        {
          "alias": "socialLinks",
          "value": {
            "model": "BasicBlockListModel"
          },
          "editorAlias": "Umbraco.BlockList"
        },
        {
          "alias": "isDisplaySocialIconsOnTopHeader",
          "value": {
            "model": "BasicPropertyValue"
          },
          "editorAlias": "Umbraco.TrueFalse"
        },
        {
          "alias": "footerNavigation",
          "value": {
            "model": "BasicBlockListModel"
          },
          "editorAlias": "Umbraco.BlockList"
        },
        {
          "alias": "footerNavLink",
          "value": {
            "model": "BasicMultiUrlPicker"
          },
          "editorAlias": "Umbraco.MultiUrlPicker"
        }
      ]
    }
  }
}
i have one property mainNavigation, how do i get value of that property ?
s
FYI: you can (and should!) easily format your code on Discord by using three backticks around it, you can even add syntax highlighting: https://techswift.org/2021/07/02/how-to-format-text-as-a-block-snippet-of-code-in-discord/
n
@Nikcio i guess i got it... going more deep with different scenarios
n
@Nilay The
Properties
property in the request always gives you all properties on a content node in the format you're seeing where you specify more generally what data you want. If you have one specific property you want the value of I would suggest using
NamedProperties
this works by selecting a composition or content type and on all content you request if it has that composition or content type you can get the property value. See more at: https://nikcio.github.io/Nikcio.UHeadless/v4/fundamentals/querying/properties/