I have two jsonata files but i have to take particular field from jsonata1 and merge that particular field in jsonata2 - jsonata

For example
Json1:
{
"Data":"123",
"Data1":"345"
}
Jsonata1:
{
"Data":$.Data,
"Data1":$.Data1
}
Json2:
{
"Prod":"675",
"Prod2":"564"
}
Jsonata2:
{
"Prod":$.Data
}
How can I use like this if u observed my jsonata2 I call the jsonata1 feild data
I can't find any suggestions
Please help me resolve the issue

Related

Filter nested array in graphQL

I am trying to filter an array of quotes based on what work or event the quote is referencing.
I only want the quotes referencing the current work the user is visiting. I've tried filtering, but I can't get it to work.
query MyQuery {
allSanityQuote {
edges {
node {
work {
... on SanityEvent {
_id
}
}
}
}
}
}
I want the _id in SanityEvent to match wphb0cG6N3lm4RQzm1xf51
Is SanityEvent a so called union? I've tried to read the graphQL documentation, but can't seem to find any example of this.

Reusing GraphQL fragments

I am using Prismic, and I have two identical custom types, one is called Content and one is called Theme. Their data is identical so I would like to reuse my fragments, is it possible?
An example fragment looks like:
import { graphql } from 'gatsby'
export const CollectionFragment = graphql`
fragment CollectionFragment on PrismicContentBodyCollection {
...
}
`
So right now it is hardcoded to PrismicContentBodyCollection.
A GraphiQL example would look like:
query MyQuery {
allPrismicTheme {
nodes {
data {
body {
... on PrismicThemeBodyHero {
slice_type
}
}
}
}
}
allPrismicContent {
nodes {
data {
body {
... on PrismicContentBodyHero {
slice_type
}
}
}
}
}
}
I'm not 100% sure, but I don't think this is possible because it needs to be specified with the type that matches the type of document you're looking for to make sure that your query is valid and that the fields you are trying to receive actually exist on the object.
So in your case, if you're looking for the Collection Slice, the fragments would need to be
PrismicThemeBodyCollection and PrismicContentBodyCollection respectively.
I have made a few tests myself and I keep getting errors that say I'm missing the correct content type name

Get Product Metafields Data with GraphQL / BigCommerce

I'm trying to retrieve product metafields on BigCommmerce via GraphQL. The below code throws an error
query {
site {
product(entityId:639) {
sku
path
metafields(namespace: "App_Namespace", keys: "color_key") {
edges {
node {
id
value
}
}
}
}
}
}
Meta field information
Namespace App_Namespace
Key color_key
Description Colour
Value Blue | Grey | Yellow
Would appreciate any help on above. Thanks
The "keys" argument expects an array of keys. So even if you just want one key, submit it as an array of one:
query {
site {
product(entityId: 639) {
sku
path
metafields(namespace: "App_Namespace", keys: ["color_key"]) {
edges {
node {
id
value
}
}
}
}
}
}
Check out this link for more examples:
https://developer.bigcommerce.com/changelog#posts/graph-ql-storefront-api-updates-metafields-on-product-category-brand-variant
You also need to make sure that these requirements are met,
otherwise, even if the query is correct, you won't be able to get the metafields in the query:
The metafield must be marked with a permission_set of read_and_sf_access or write_and_sf_access in order to be exposed to the API. Metafields with any other permission value will be hidden.

Filter empty nodes on GitHub GraphQL API

I'm trying to use the V4 API of GITHUB to get a list of my assigned issues along with its labels and references.
After some time I got the query you can see below, which works exactly how I want.
There is however, a problem: it includes a lot of empty nodes I am not interested at. For example, if I want to get all the CrossReferencedEvent that are issues I will get a lot of empty nodes on the timeline edges array because the other events: LabeledEvent, ReferencedEvent, AssignedEvent etc.
How can I filter out those so I only get the events I am interested at?
Is this a limitation of graphql? Am I forced to remove the useless nodes locally?
This is the query that I have currently
{
search(query: "assignee:danielo515", type: ISSUE, last: 100) {
edges {
node {
... on Issue {
number
title
state
timeline(first: 10) {
edges {
node {
... on CrossReferencedEvent {
source{
... on Issue {
title
number
}
}
}
}
}
}
labels(last: 10) {
nodes {
name
color
}
}
repository {
name
}
}
}
}
}
}
One improvement I can make is, on the query part add is:issue. This will . save me all the empty nodes at the root edges array, but I don't see how to do the same for the nested timeline.
Thanks in advance

How can I do a WpGraphQL query with a where clause?

This works fine
query QryTopics {
topics {
nodes {
name
topicId
count
}
}
}
But I want a filtered result. I'm new to graphql but I see a param on this collection called 'where', after 'first', 'last', 'after' etc... How can I use that? Its type is 'RootTopicsTermArgs' which is likely something autogenerated from my schema. It has fields, one of which is 'childless' of Boolean. What I'm trying to do, is return only topics (a custom taxonomy in Wordpress) which have posts tagged with them. Basically it prevents me from doing this on the client.
data.data.topics.nodes.filter(n => n.count !== null)
Can anyone direct me to a good example of using where args with a collection? I have tried every permutation of syntax I could think of. Inlcuding
topics(where:childless:true)
topics(where: childless: 'true')
topics(where: new RootTopicsTermArgs())
etc...
Obviously those are all wrong.
If a custom taxonomy, such as Topics, is registered to "show_in_graphql" and is part of your Schema you can query using arguments like so:
query Topics {
topics(where: {childless: true}) {
edges {
node {
id
name
}
}
}
}
Additionally, you could use a static query combined with variables, like so:
query Topics($where:RootTopicsTermArgs!) {
topics(where:$where) {
edges {
node {
id
name
}
}
}
}
$variables = {
"where": {
"childless": true
}
};
One thing I would recommend is using a GraphiQL IDE, such as https://github.com/skevy/graphiql-app, which will help with validating your queries by providing hints as you type, and visual indicators of invalid queries.
You can see an example of using arguments to query terms here: https://playground.wpgraphql.com/#/connections-and-arguments

Resources