Closed Jones-S closed 5 years ago
Look up 'inline fragments' on Types, Jonas.
How you get any but the most primary Element fields.
Grüss
Thank you for the quick response. I'll check it out. --- Edit:
If I read this correctly: (from https://graphql.org/learn/queries/#inline-fragments)
... on Droid {
primaryFunction
}
The ...on
part is an inline fragment, correct?
But why would that be important in my case. I use ...on stuff later for matrix fields.
As far as I understand inline Fragments are used in cases where the type is not just one. But in my case it is. Or am I completely misunderstanding something?
You need them any time the fields are not part of the primary target, which in Craft's case is Element.
You are presumably querying on an Entry. Then any fields you add as properties of its Section,, your fields defined for it, will only be present on the compound type GraphQL generates.
That's why there's emphasis on the 'Documentation' or 'Schema' abilities in Graphiql -- so you can look these types up, as the Craft Entry Type of interest often also forms part of the compound name.
In CraftQL syntax, the first entry type is [often?] merged with the base name, so yes, as you suggest,
... on Droid {
body # body is field of your Droid Entry, not of Element...
image {
title
url
}
primaryFunction # etc.
}
In the new Craft GraphQL syntax, it's further spelled out, so something like this:
... on Droid_droid_Entry {
body
image {
title
url
}
primaryFunction # etc.
}
Gruezi, properly this time
Grüezi is rather used as a greeting :).
Thanks for elaborating, I still don't fully understand. I will try to read some stuff about 'Documentation' or 'Schema' abilities in Graphiql.
But also today, the same query is not warning me at all, and everything looks fine. Maybe it was a bug?...
I can tell you what the situation looks like...
entries
is a normal term for Craft. You are not permitted at the moment of this query to access entries; therefore it's an unknown name to CraftQL. That's the way the security operates, so there is no direct statement of permissions being involved possible.entries
didn't exist.Field
wasn't known.slug
and title
, those I believe are both properties of Entries in general; thus in your first post should have worked, and presumably do nowprimaryFunction
, which is surely not a base Entry field. Thus it must be a field of a particular Section's particular entryType
, so that it requires a specific inline fragment naming that combination, before it can be seen by GraphQL. So I explained.Ok, and thanks for reminding me where speech also places Gruezi
, so I should have known for notes also - it was a late night instant. Mainly I was intending to be polite without the Hochdeutsch, which I could also know better. My time was very busy, full of Germans who wanted to polish their English on the demanding and largely non-technical matters we dealt with across many cultures constantly, thus with no chance to do formal language study. I like to keep up a bit with what I could do reasonably, read newspapers, and so the FAZ, Süddeutsch Zeitung, and Basler posts are in my in-tray...
Anyway, I should say that I much liked, appreciated, and enjoyed Switzerland, through all efforts and struggles of the times. I'd still be happily living there, with the planned brass plate on the doorpost, if those times hadn't intervened.
OK wow. What a long and complete answer. Thank you very much. I am not sure what could have caused the error. Maybe a thing with the token settings, but this would not explain why I got a return for my query. If it reappears I try to go through each of your points. Thank you.
@narration-sd thanks man beena huge help, right on the time i needed , appreciated
I am using a query like:
Within graphiql it gives me this error
But when I run the command I get what I wanted. So it actually works... Does anyone know if the error is wrong or if my query indeed is wrong?
Thank you
Cheers