Basically I want to get localized values for the entries linking to my unique entry.
movie(id: $movieId) {
linkedFrom {
spanishMovieLocations: movieLocationCollection(locale: "es-ES") {
items {//fields with localized values}
}
}
}
But instead I get no results in my collection array. Querying directly for movieLocationCollection(locale: "es-ES") gets me localized values and has some matching movie.sys.id that is used in $movieId.
This works fine, but then I dont get the localized fields I need.
movie(id: $movieId) {
linkedFrom {
movieLocationCollection {
items {//fields with non-localized values}
}
}
}
from the contentful site:
We ... made the querying of localized reference content easier by introducing a new allowedLocales argument.
https://www.contentful.com/blog/2020/12/03/three-new-graphql-features-2020/
movie(id: $movieId) {
linkedFrom(allowedLocales: ["es-ES"]) {
movieLocationCollection {
items {//fields with non-localized values}
}
}
}
In my project I had to include both locales
query ($parner: String) {
partnerCollection(limit: 1, locale: "fr-CA", where: {title: $parner}) {
items {
title
sys {
id
}
linkedFrom(allowedLocales: ["en-US", "fr-CA"]) {
benefitCollection(limit: 3) {
total
items {
title
}
}
}
}
}
}
Related
Asset Hotspots have 'add Data' in context menu.
We can add related objects / fileds / documents / etc there.
How to export this data in GraphQL? I see only '__typename' property.
Sample query:
{
getCategoryListing(defaultLanguage: "en") {
totalCount
edges {
node {
categoryimage {
image {
fullpath
}
hotspots {
name
top
height
left
width
data {
__typename
}
}
marker {
name
top
left
data {
__typename
}
}
}
}
}
}
}
Yes, this functionality is provided by GraphQL itself.
Check that you granted reading rights to object class that you are trying to access otherwise you will see 'object: null'
learch which object types you get using __typename
When you know the type name and have access to that object, just get its data
Sample:
... on property_text {
type
name
text
}
or
... on object_product {
sku
}
See the documentation here: https://pimcore.com/docs/data-hub/current/GraphQL/Query/Query_Samples/Sample_Element_Properties.html
Sample query to get additional data from Pimcore Hotspots and Markers on Hotspotimage:
{
getCategoryListing(defaultLanguage: "en") {
totalCount
edges {
node {
id
categoryimage {
image {
fullpath
}
hotspots {
name
top
height
left
width
data {
__typename
... on property_text {
type
name
text
}
... on property_object {
type
name
object {
__typename
... on object_product {
sku
}
... on element {
__typename
}
}
}
}
}
marker {
name
top
left
data {
__typename
... on property_text {
type
name
text
}
... on property_object {
type
name
object {
__typename
... on object_product {
sku
}
}
}
}
}
}
}
}
}
}
If we have an Author with no beacons to Articles and thus WroteArticles was null and we wanted to only return Authors who had non-empty/non-null WroteArticles, how could that be done?
As an example we can use the Weaviate demo site
I've tried filter operations using where and various operators, but I must be missing something obvious. Example of a query I've tried on my own data set below, where I did have a Thing with no beacons.
{
Get {
Things {
Author (where:{
operator:Equal,
path:["WroteArticles"]
valueString:" "
}){
name
WroteArticles {
... on Article {
InPublication {
... on Publication {
name
}
}
}
}
}
}
}
}
You can now do this as follows (also in the documentation):
{
Get {
Things {
Author(
where:{
valueInt: 2
operator:GreaterThanEqual
path: ["WroteArticles"]
}
) {
name
WroteArticles {
... on Article {
title
}
}
}
}
}
}
I have the following query :
{
allPeople {
people {
name
filmConnection {
films {
title
}
}
}
}
}
I would like to select all people that have a film connection with the title a new hope. How do i select this specific thing from the API. I could also just get it like this and handle it in the code. But surely there is a better way.
What i'd expect :
{
allPeople {
people {
name
filmConnection {
films {
title : "a new hope"
}
}
}
}
}
That didnt work..
Try out here in this playground :
https://graphql.org/swapi-graphql?query=%7B%0A%20%20allPeople%20%7B%0A%20%20%20%20people%20%7B%0A%20%20%20%20%20%20name%0A%20%20%20%20%20%20filmConnection%20%7B%0A%20%20%20%20%20%20%20%20films%20%7B%0A%20%20%20%20%20%20%20%20%20%20title%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A
graphql queries ... are not for building [sql] queries ;)
this is more for defining shape of required data
parameter CAN BE passed to deeper child (f.e. can be used to filter films)
{
allPeople {
people {
name {
filmConnection {
films(title_eq:"a new hope") {
title
}
}
}
}
}
}
... if API supports this kind of filtering for films
... but it won't filter people - you'll have all people AND filtered films (for all people) because filters won't work on parents.
You CAN have custom API that will be this kind of filtering aware, f.e.
{
allPeople {
people(connectedFilmTitle_eq:"a new hope") {
name {
filmConnection {
films {
title
}
}
}
}
}
}
customized (not automatically gnerated) peolpe resolver can make appriopriate query [on joined tables] and return structure you're asking for.
In that case probably you don't need deeper structures - ...filmConnection { films { title - you know this data earlier (filter parameters).
... but probably you have a many2many relation and cen reverse this query:
{
allFilms {
films(title_eq:"a new hope") {
title {
peoleConnection {
people {
name
}
}
}
}
}
}
I have the following query:
{
entity(id: "theId") {
source1: media(source: 1){
images{
src, alt
}
}
source2: media(source: 2){
images{
src, alt
}
}
}
}
That give me a result like:
{
"entity": [
{
"source1": {
"images": [{"src": "", "alt": ""}]
},
"source2": {
"images": [{"src": "", "alt": ""}]
}
}
]
}
Is there a way to have a single result of source1 and source2, executing source1 and if it has no result it use source2 as fallback?
You are querying two fields (source1, source2) so something has to come back for both of them (null being a possible option). If you want to check them in a sequence you should probably break the query in two and run them one at the time from the client.
Could you perhaps change so you only query a single source field and have the resolver (on the server) return what makes sense based on what is available, so to speak? Like this:
{
entity(id: "theId") {
source: media(sourcesList: [1, 2]){
images{
src, alt
}
}
}
}
where sourceList is the sources to try, in order. So the resolver (server) can then check if source 1 is available and if not return source 2.
You could also add a field to let the client know which source was actually returned from the proposed list (sourceNumberReturned below would return 1 if source 1 was returned, otherwise 2).
{
entity(id: "theId") {
source: media(sourcesList: [1, 2]){
images{
src, alt
}
sourceNumberReturned
}
}
}
I'm trying to use Gatsby's /___graphq debugger and the README file for gatsby-source-prismic says you can return slices. So below I'm returning the slice with a name PrismicProductBodySteps.
{
allPrismicHomePage {
edges {
node {
data {
seo_title
body {
__typename
... on PrismicProductBodySteps {
}
}
}
}
}
}
}
}
Can someone explain to me what ... on PrismicProductBodySteps means ?
In a gatsby component I've seen this as an example.
body {
... on PrismicProductsBodySteps {
...ProductStepsFragment
}
Can anyone explain to me what the ...ProductStepsFragment means ?
PrismicProductBodySteps would be a custom node type name representing a dynamic series of content blocks. That custom node type name is coming from a Prismic data model; yours will likely be different.
According to the gatsby-source-prismic documentation, using custom node type names requires you to figure out what they are first:
The easiest way to get the type of nodes is to use the /___graphql
debugger and run the below query (adjust the document type and field
name).
{
allPrismicPage {
edges {
node {
id
data {
body {
__typename
}
}
}
}
}
}
Once you have your custom node type name, you can use a GraphQL fragment to pull data specific to each fragment. Again, this would depend on how you have the fragments defined in your data model, but it would look something like this:
{
allPrismicHomePage {
edges {
node {
data {
seo_title
body {
__typename
... on PrismicYourContentBlockOne {
text {
html
}
}
... on PrismicYourContentBlockTwo {
text {
html
}
}
... on PrismicYourContentBlockThree {
text {
html
}
}
}
}
}
}
}
}