gatsby custom source plugin - need help to get all the data - node.js

I am working on my first custom source plugin for gatsby, but I am stuck now..
Its working so far that I get the data I need create node, but not for all the data.
the response i get from the api looks like this
{
"section1": {
"date": "...",
"moreinformartion": "...",
},
"section2": [
{
"sub1": {
"information": "..."
}
},
{
"sub2": {
"information": "..."
}
},
{
"sub2": {
"information": "..."
}
}
]
}
But with all the tutorials out there, I was "only" able to get a node for every sub in section2
result.data.roster.forEach(data => {
const node = {
...data,
id: createNodeId(`KILL-setup-${data.character.name}`),
internal: {
type: 'KILLSetup',
contentDigest: createContentDigest(data)
}
};
actions.createNode(node);
});
How can I get 1 node, with all the data inside?

Related

node-ews Update email to mark as read

I'm using "node-ews" library version 3.5.0, but when I try to update any property I get the following error:
{
"ResponseMessages":{
"UpdateItemResponseMessage":{
"attributes":{
"ResponseClass":"Error"
},
"MessageText":"An internal server error occurred. The operation failed., Object reference not set to an instance of an object.",
"ResponseCode":"ErrorInternalServerError",
"DescriptiveLinkKey":0,
"Items":null
}
}
}
I'm trying to mark email as read using the following code:
const markFolderAsRead = async (ews, id, changeKey) => {
const args = {
attributes: {
MessageDisposition: "SaveOnly",
},
ItemChanges: {
ItemChange: {
ItemId: {
attributes: {
Id: id,
ChangeKey: changeKey,
},
},
Updates: {
SetItemField: {
FieldURI: {
attributes: {
FieldURI: "message:IsRead",
},
Message: {
IsRead: true,
},
},
},
},
},
},
};
await ews.run("UpdateItem", args).then((result) => {
console.log("email read:", JSON.stringify(result));
});
};
I tried several modifications, including trying to update another fields, but none of it worked.
I followed this documentation: https://learn.microsoft.com/pt-br/exchange/client-developer/web-service-reference/updateitem-operation
And the lib doesn't show any example of it, but when I change the json to a wrong "soap" construction the error show different messages, or even if I do not pass any of the parameters required as "ChangeKey".
So, maybe this error is something relate to microsoft ews soap construction that I'm missing parameters, or so.
Got it working!
My JSON was wrong. The FieldURI was finishing after the message attribute, it should be before.
Correct JSON:
const args = {
attributes: {
MessageDisposition: "SaveOnly",
ConflictResolution: "AlwaysOverwrite",
SendMeetingInvitationsOrCancellations: "SendToNone",
},
ItemChanges: {
ItemChange: {
ItemId: {
attributes: {
Id: id,
ChangeKey: changeKey,
},
},
Updates: {
SetItemField: {
FieldURI: {
attributes: {
FieldURI: "message:IsRead",
},
},
Message: {
IsRead: "true",
},
},
},
},
},
};

Sap Commerce Cloud cannot generate build with custom addon

I've installed in my local environment customgigyaaddon (an extended version of gigyaloginaddon), injected in my customstorefront and added to localextensions.xml and compiled without any problems, however, when I try to generate a build of this same version in sap commerce cloud, it throws me the following exception :
/opt/workspace/build/commerce-
suite/hybris/bin/platform/resources/ant/antmacros.xml:587:
java.lang.IllegalArgumentException: cannot merge namespace ((customgigyaaddon)) into
((<merged>)) due to duplicate type code 'gigyaconfig2cmssite' : GigyaConfig2CMSSite::
((customgigyaaddon))::YRelation[customgigyaaddon-items.xml:14(RelationTypeTagListener)]
<>GigyaConfig2CMSSite::((gigyaservices))::YRelation[gigyaservices-
items.xml:65(RelationTypeTagListener)]
My localextensions-cloud.xml is exactly the same as my localextensions.xml and in the manifest.json I've declared the addon injection as follows:
{
"commerceSuiteVersion":"2105",
"enableImageProcessingService": true,
"extensionPacks" : [
{
"name" : "hybris-commerce-integrations",
"version" : "2108.2"
}
],
"extensions":[
"sapymktcommon",
"sapymktclickstream",
"sapymktrecommendation",
"sapymktrecommendationbuffer",
"sapymktrecommendationwebservices",
"cloudmediaconversion",
"mediaconversionbackoffice",
"sapymktsegmentation",
"sapymktsegmentationb2b",
"sapymktsegmentationwebservices",
"personalizationymkt",
"integrationbackoffice",
"outboundsyncbackoffice",
"sapymktdatareplication",
"assistedservicestorefront"
],
"useConfig":{
"properties":[
{
"location":"config/local-dev.properties",
"persona":"development"
},
{
"location":"config/local-stag.properties",
"persona":"staging"
},
{
"location":"config/local-prd.properties",
"persona":"production"
}
],
"extensions":{
"location":"/config/localextensions-cloud.xml"
},
"solr":{
"location":"customSolr"
}
},
"storefrontAddons":[
{
"addons":["commerceorgsamplesaddon","smarteditaddon","textfieldconfiguratortemplateaddon","customerticketingaddon","orderselfserviceaddon","consignmenttrackingaddon","marketplaceaddon","notificationaddon","customerinterestsaddon","stocknotificationaddon","customaddon","configurablebundleaddon","sapymktrecommendationaddon"],
"storefronts":["customstorefront"],
"template":"yacceleratorstorefront"
},
{
"addons":["customgigyaaddon"],
"storefronts":["customstorefront"],
"template":"yacceleratorstorefront"
}
],
"aspects":[
{
"name":"backoffice",
"webapps":[
{
"name":"mediaweb",
"contextPath":"/medias"
},
{
"name":"backoffice",
"contextPath":"/backoffice"
},
{
"name":"hac",
"contextPath":"/hac"
},
{
"name":"dathubadapter",
"contextPath":"/datahubadapter"
},
{
"name":"oauth2",
"contextPath":"/authorizationserver"
},
{
"name": "customstorefront",
"contextPath": "/valet"
}
{
"name": "personalizationsmartedit",
"contextPath": "/personalizationsmartedit"
},
{
"name": "personalizationpromotionssmartedit",
"contextPath": "/personalizationpromotionssmartedit"
},
{
"name": "personalizationwebservices",
"contextPath": "/personalizationwebservices"
},
{
"name": "personalizationsearchsmartedit",
"contextPath": "/personalizationsearchsmartedit"
},
{
"name":"previewwebservices",
"contextPath":"/previewwebservices"
},
{
"name":"permissionswebservices",
"contextPath":"/permissionswebservices"
},
{
"name":"ycommercewebservices",
"contextPath":"/rest"
}
]
}
],
"webapps":[
{
"name":"customstorefront",
"contextPath":"/custom"
}
]
},
{
"name":"backgroundProcessing",
"properties":[
{
"key":"cluster.node.groups",
"value":"integration,yHotfolderCandidate"
}
],
"webapps":[
{
"name":"hac",
"contextPath":"/hac"
},
{
"name":"mediaweb",
"contextPath":"/medias"
}
]
}
]
}
],
"properties": [
{
"key":"configFile",
"value":"/opt/hybris/bin/custom/resources/update-config.json"
}
]
}
Looking the exception it looks like there is already an relation gigyaconfig2cmssite declared in gigyaservices-items.xml, however this is not true since this specific relation is only declared in customgigyaservices-items.xml.
Am I missing something? I feel really lost
if you analyzed the issue as follows:customgigyaaddon-items.xml and gigyaservices-items.xml, both contain the entry.
Otherwise, have you tried to ant clean all the platform? Also, set generate and auto-create as false and removed the extends.

How to fix graphql-tools/stitch stitched schemas returning null for aliased fields on union types?

The bug
Aliased attributes in union types resolve to null instead of their correct value when using schema stitching to combine two remote schemas.
The same query returns the correct result on the "non-stitched" schema when issued to the non-stitched schema at localhost:/4001/graphql
To Reproduce
Steps to reproduce the behavior:
checkout the github repo
follow the README.md steps:
npm i && npm run start
gateway on localhost:4444/graphql
remote-1 on localhost:4001/graphql
remote-2 on localhost:4002/graphql
go to localhost:4444/graphql (the stitched schema) and query
query {articles {title {
... on TitleOne {text}
... on TitleTwo {renamedText: text}
}}}
Expected behavior
result should contain correct values. E.g.
{
"data": {
"articles": [
{
"title": {
"text": "hello world"
}
},
{
"title": {
"renamedText": 1
}
},
{
"title": {
"renamedText": 2
}
},
{
"title": {
"text": "bye"
}
}
]
}
}
** Actual Behaviour **
result contains "null" for aliased fields
{
"data": {
"articles": [
{
"title": {
"text": "hello world"
}
},
{
"title": {
"renamedText": null
}
},
{
"title": {
"renamedText": null
}
},
{
"title": {
"text": "bye"
}
}
]
}
}
Environment:
OS: ubuntu 18.04
"#graphql-tools/load": "^7.5.8",
"#graphql-tools/schema": "^8.3.8",
"#graphql-tools/stitch": "^8.6.6",
"#graphql-tools/url-loader": "^7.9.11",
"#graphql-tools/wrap": "^8.4.13",
NodeJS: v14.19.1
Does anyone know how I can get this to return the correct values instead of "null"?

parse json in nodejs with : in the json keys

My nodejs code receives a response from a HTTP POST call which is in xml. I convert it to json using xml2js, and now I need to read this so as to get the data of one of the json keys.
This is how a part of my json data looks. I am trying to read this as follows:
var base64encoded = jsonxml."soapenv:Body".runReportResponse.runReportReturn.reportBytes;
However, when I run this i get the error message:
jsonxml."soapenv:Body".runReportResponse.runReportReturn.reportBytes;
^^^^^^^^^^^^^^
SyntaxError: Unexpected string.'
I have also tried by removing the double quotes, but then it gives exception to the colon (:) which appears in the data. How do I read such kind of data?
Entire json:
[
{
"Envelope": {
"$": {
"xmlns:soapenv": "http://schemas.xmlsoap.org/soap/envelope/",
"xmlns:xsd": "http://www.w3.org/2001/XMLSchema",
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance"
},
"Body": {
"runReportResponse": {
"$": {
"xmlns": "http://xmlns.oracle.com/oxp/service/PublicReportService"
},
"runReportReturn": {
"metaDataList": {
"$": {
"xsi:nil": "true"
}
},
"reportBytes": "MzAwMDAwMDA0Mzk5ODEwLERDT0cgQ29ycG9yYXRlIEJVDQozMDAwMDAwMDk0ODE4MzEsREVMRlRMQUJfVVNfQlVTSU5FU1NfVU5JVA0KMzAwMDAwMDAzMDYyNTI1LERFTEhJVEVDSF9VU19CVVNJTkVTU19VTklUDQozMDAwMDAwMDMwNjE1ODMsREVMTFMgVVMgQlUNCjMwMDAwMDAwMzE3OTE0NixERUxNRkcgVVMgQlUNCjMwMDAwMDAxMDI1NDA1NyxESEMgQ29ycG9yYXRlDQo=",
"reportContentType": "text/plain;charset=UTF-8",
"reportFileID": {
"$": {
"xsi:nil": "true"
}
},
"reportLocale": {
"$": {
"xsi:nil": "true"
}
}
}
}
}
}
}
]
I've updated the answer base on your new JSON (thank you!). It looks like the problem is maybe that each property in the JSON is really an array.
I'd suggest if you don't want this behaviour, to have a look at the explicitArray options in the xml2js options object setting it to false.
e.g. :
explicitArray (default: true): Always put child nodes in an array if true; otherwise an array is created only if there is more than one.
This might simplify accessing properties!
let response = [
{
"Envelope": {
"$": {
"xmlns:soapenv": "http://schemas.xmlsoap.org/soap/envelope/",
"xmlns:xsd": "http://www.w3.org/2001/XMLSchema",
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance"
},
"Body": {
"runReportResponse": {
"$": {
"xmlns": "http://xmlns.oracle.com/oxp/service/PublicReportService"
},
"runReportReturn": {
"metaDataList": {
"$": {
"xsi:nil": "true"
}
},
"reportBytes": "MzAwMDAwMDA0Mzk5ODEwLERDT0cgQ29ycG9yYXRlIEJVDQozMDAwMDAwMDk0ODE4MzEsREVMRlRMQUJfVVNfQlVTSU5FU1NfVU5JVA0KMzAwMDAwMDAzMDYyNTI1LERFTEhJVEVDSF9VU19CVVNJTkVTU19VTklUDQozMDAwMDAwMDMwNjE1ODMsREVMTFMgVVMgQlUNCjMwMDAwMDAwMzE3OTE0NixERUxNRkcgVVMgQlUNCjMwMDAwMDAxMDI1NDA1NyxESEMgQ29ycG9yYXRlDQo=",
"reportContentType": "text/plain;charset=UTF-8",
"reportFileID": {
"$": {
"xsi:nil": "true"
}
},
"reportLocale": {
"$": {
"xsi:nil": "true"
}
}
}
}
}
}
}
];
console.log("Report bytes: ", response[0].Envelope.Body.runReportResponse.runReportReturn.reportBytes);

How can we list all the branches in a repo using github graphQL api?

I am trying to check if a branch already exists in repo for that first I need to get all the open branches present.
query searhbranches {
repositoryOwner(login: "username"){
repository(name: "config-replica"){
name
[branches] // something like this but its not available
}
}
}
You want to look at the refs node inside repository. Here's an example query that works for me:
{
repository(owner: "desktop", name: "desktop") {
refs(first: 50, refPrefix:"refs/heads/") {
nodes {
name
}
}
}
}
This is what it returns:
{
"data": {
"repository": {
"refs": {
"nodes": [
{
"name": "add-lfs-path-lookup"
},
{
"name": "add-notes-lookup-to-parser"
},
{
"name": "ahead-behind-toggle-spike"
},
{
"name": "all-stash-functions"
},
...
]
}
}
}
}
...

Resources