Nikcio
01/28/2022, 3:04 PMTackleMcClean 🏅
02/24/2022, 8:28 PMNikcio
02/24/2022, 8:57 PMNikcio
02/24/2022, 8:58 PMTackleMcClean 🏅
02/24/2022, 10:23 PMNikcio
02/25/2022, 5:53 AMNikcio
02/25/2022, 5:56 AMTackleMcClean 🏅
02/25/2022, 10:55 AMNikcio
02/25/2022, 11:45 AMTackleMcClean 🏅
02/28/2022, 11:12 AMTackleMcClean 🏅
02/28/2022, 11:12 AMTackleMcClean 🏅
02/28/2022, 11:12 AMTackleMcClean 🏅
02/28/2022, 11:13 AMabosulteUrl
instead of absoluteUrl
also 🙂Nikcio
02/28/2022, 2:42 PMNikcio
02/28/2022, 2:43 PMNikcio
02/28/2022, 2:43 PMTackleMcClean 🏅
02/28/2022, 2:45 PMTackleMcClean 🏅
02/28/2022, 2:45 PMTackleMcClean 🏅
02/28/2022, 4:25 PMContentGraphType.cs
I was thinking - wouldn't it be possible to create your own class inheriting this, and for this class add the fields you will be using for the relevant page's document type?
So you make your own version of this class representing a specific document type, and this could (possibly) give you type hinting via graphql attributes?
And then somehow write your queries to assume it is working with this specific model?Nikcio
02/28/2022, 5:35 PMTackleMcClean 🏅
02/28/2022, 7:14 PMTackleMcClean 🏅
02/28/2022, 7:36 PMContentQuery
and add customs fields there, and then feed your own list (including the default ContentQuery
and PropertyQuery
to graphQLExtentions
when calling AddUHeadless
?Nikcio
02/28/2022, 8:33 PMTackleMcClean 🏅
03/01/2022, 8:52 AMTackleMcClean 🏅
03/01/2022, 9:57 AMHomeQuery
, public class HomeQuery : ContentQueryBase<HomeGraphType<PropertyGraphType>, PropertyGraphType>
And my own HomeGraphType
by basically copying the whole ContentGraphType
class and changing the class signature to:
public class HomeGraphType<TPropertyGraphType> : ElementGraphType<TPropertyGraphType>, IHomeGraphTypeBase<TPropertyGraphType>
where TPropertyGraphType : IPropertyGraphTypeBase
{
Also adding an extra interface IHomeGraphTypeBase
Goal to get some new object type to show up in the schema reference
However when trying to follow the flow of classes and interfaces I'm guessing you would also need alter the ContentRepository as well?
Sadly I'm a beginner in C# but perhaps I can serve as a good use case/guinea pig for a user of the package 🙂
As someone who is trying to add a model.
Our approach is that we're not afraid to write somewhat rigid/hard coded connections between our Umbraco document types and the graphql files, as long as we do it in a reproducible way, as then we can have a very clear API for the frontend team to graphql query against.Nikcio
03/01/2022, 8:00 PMNikcio
03/01/2022, 8:01 PMNikcio
03/01/2022, 8:03 PMTackleMcClean 🏅
03/01/2022, 8:10 PMTackleMcClean 🏅
03/01/2022, 8:11 PMTackleMcClean 🏅
03/01/2022, 8:17 PMCustomContentGraphType
for example, extending`ContentGraphType`
2. a CustomContentQuery
extending ContentQueryBase<CustomContentGraphType<PropertyGraphType>, PropertyGraphType>
and from that I should (hopefully) be able to have a custom property type up and running in the schema reference as well?TackleMcClean 🏅
03/01/2022, 8:49 PMNikcio
03/01/2022, 8:57 PMTackleMcClean 🏅
03/07/2022, 10:23 AM{
contentById(id: 1061) {
myCustomString
}
}
Results in:
{
"errors": [
{
"message": "Unexpected Execution Error",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"contentById"
]
}
],
"data": {
"contentById": null
}
}
Regardless of what property I'm asking for it breaks like this.
I then did a guess and tried to do:
{ (builder) =>
builder
.AddTypeExtension<ContentQuery>()
.AddTypeExtension<CustomContentQuery>()
.AddTypeExtension<PropertyQuery>()
.AddTypeExtension<MediaQuery>()
};
But it seems you can't include ContentQuery as long as you're including a CustomContentQuery.
It fails to compile complaining about middleware order.
I also tried extending ElementGraphType
instead of ContentQuery
, figuring there was some collision of trying to use something already defined, but same issue.
Any guess on what to try?Nikcio
03/07/2022, 1:32 PMTackleMcClean 🏅
03/07/2022, 1:33 PMNikcio
03/07/2022, 1:33 PMNikcio
03/07/2022, 1:33 PMTackleMcClean 🏅
03/07/2022, 1:34 PMdotnet restore
, however I might be wrong in my assumption that that will give me the latest version?
should I also run dotnet clean
/ remove folders?TackleMcClean 🏅
03/07/2022, 1:35 PMTackleMcClean 🏅
03/07/2022, 1:43 PMvar graphQLExtensions = new List<Func<IRequestExecutorBuilder, IRequestExecutorBuilder>>
{ (builder) =>
builder
.AddTypeExtension<CustomContentQuery>()
.AddTypeExtension<PropertyQuery>()
.AddTypeExtension<MediaQuery>()
};
in my Startup.cs
I'm running .net 6.0 btw.TackleMcClean 🏅
03/07/2022, 1:45 PM{
contentById(id: 1061) {
url
}
}
I get the "message": "Unexpected Execution Error"
But no error output in my logging whatsoever, very strange.
The two files, CustomContentGraphType.cs
and CustomContentQuery.cs
are exactly as in the documentation exampleNikcio
03/07/2022, 1:45 PMpublic class CustomProfile : Profile
{
public CustomProfile()
{
CreateMap<IPublishedContent, CustomContentGraphType<PropertyGraphType>>()
.IgnoreAllPropertiesWithAnInaccessibleSetter()
.ForMember(dest => dest.Content, opt => opt.MapFrom(src => src));
}
}
Nikcio
03/07/2022, 1:46 PMNikcio
03/07/2022, 1:46 PMautomapperAssemblies: new List<Assembly> { Assembly.GetAssembly(typeof(Startup)) }
Nikcio
03/07/2022, 1:46 PMNikcio
03/07/2022, 1:47 PMTackleMcClean 🏅
03/07/2022, 1:48 PMNikcio
03/07/2022, 1:48 PMNikcio
03/07/2022, 1:48 PMTackleMcClean 🏅
03/07/2022, 1:49 PMTackleMcClean 🏅
03/07/2022, 1:49 PMTackleMcClean 🏅
03/07/2022, 1:50 PMTackleMcClean 🏅
03/07/2022, 1:50 PMNikcio
03/07/2022, 1:54 PMTackleMcClean 🏅
03/07/2022, 1:58 PMfragment comparisonFields on Character {
name
friendsConnection(first: $first) {
totalCount
edges {
node {
name
}
}
}
}
(example from graphql.org)TackleMcClean 🏅
03/07/2022, 1:58 PMNikcio
03/07/2022, 2:03 PMNikcio
03/07/2022, 2:07 PMTackleMcClean 🏅
03/07/2022, 3:09 PMTackleMcClean 🏅
03/07/2022, 3:10 PM