Closed danielmilner closed 5 years ago
Hi @danielmilner,
if you have at least one locale defined in the plugin configuration, you'll get a node for the default language and one for each locale defined (with each localized field translated in the corresponding language). Print or filter by the lang
attribute and you should have only unique nodes ☺.
For the default language, use the lang
value any
or any locale defined in the plugin configuration.
@WhippetsAintDogs That was it! If I set the local to an empty array in the config, I get one of each node. Thanks!
You're welcome! ☺
Hey guys, Can you give an example for the query to run?
I added lang parameter to my query as such:
allCockpitWorks(lang: { eq: "en" }) {
edges {
node {
Title {
value
}
Image {
value {
childImageSharp {
fluid {
...GatsbyImageSharpFluid
}
}
}
}
Description {
value
}
Featured {
value
}
}
}
}
This is giving me the following error:
Unknown argument "lang" on field "allCockpitWorks" of type "Query"
My config looks like this:
{
resolve: "@fika/gatsby-source-cockpit",
options: {
token: "0160ee9ee9f43905a38abe64040c28",
baseUrl: "http://localhost:8888",
collections: []
},
},
I even tried adding locales: ["en"]
to the config but no luck so far.
By the way, I have not defined any language in Cockpit (I dont even know how to do that :P)
About the previous comment, I made the query work with the following snippet:
allCockpitWorks(filter: { lang: { eq: "en" } }) {...}
This is what was intended, right? Or is there something else to it too?
Hi @sudhanshu16, you got it.
When you make an 'all' query, the way to filter by the lang is filter - lang - eq - LOCALE
and when you do a regular query, you'll specify cockpitId - eq - ID, lang - eq - LOCALE
. The LOCALE can be any value you put in the locales
option or any
.
I even tried adding locales: ["en"] to the config but no luck so far. By the way, I have not defined any language in Cockpit (I dont even know how to do that :P)
The locales
option have to be identical to your Cockpit configuration, so if you have locales: ["en"]
, you should have that Cockpit configuration (config.php):
<?php
$configs = [];
$configs['languages'] = [
'default' => 'English',
];
return $configs;
When I run any
allCockpit
query, each node is returned twice.Example query:
Returns the following:
I have 4 entries in the Collection, the first 4
cockpitId
s are unique, but the last 4 are repeats.