samedi 30 octobre 2021

How to convert array of object(hasMany relationship data) to array of id?

I'm getting data back from hasura like this:

{
  "data": {
    "movies": [
      {
        "id": "584db434-5caa-475e-b3ec-e98e742f0030",
        "movieid": "abc123",
        "description": "Penquins dancing in antactica",
        "photos": [
          {
            "id": "c4d2833a-4896-42b0-ae8b-0ab9fe71d1d4"
          },
          {
            "id": "e04697e3-21fe-4f0e-8012-443f26293340"
          }
        ]
      }
    ]
  }
} 

But Ember.js can't read and render the relationship data (photos). Is it the "photos" data should be like this?

"photos": [c4d2833a-4896-42b0-ae8b-0ab9fe71d1d4, e04697e3-21fe-4f0e-8012-443f26293340]

How can I convert it in Ember? or in Hasura?




malihu jquery custom scrollbar plugin error in crossdomain loading

Iam using malihu jquery custom scrollbar plugin version 3.1.5 in my tomcat application, build using ember js runing in xxx.com. While loading that xxx.com application in the iframe of another application running at yyy.com, Iam getting object.defineProperty called on non-object in the yyy.com web console. Kindly, help me as quick as possible.

error from console




jeudi 28 octobre 2021

How do I pass an object to a component?

This question was asked in the Ember Discord.

Is there a way to pass an object into a component

<SomeComponent object={color: green} />



Trying to Customize the ApolloService to enable Authorization in Ember 3.28. Any special configuration I need to plugin the apollo.js to be my config

Ember-Octane 3.28 Configured the enviroment.js file with the graphql endpoint, My apollo.js file in the service folder looks like

import ApolloService from 'ember-apollo-client/services/apollo';
import { inject as service } from '@ember/service';
import { setContext } from '@apollo/client/link/context';

export default class OverridenApollo extends ApolloService {
  @service session;

  link() {
    let httpLink = super.link();

    let authLink = setContext((request, context) => {
      return this._runAuthorize(request, context);
    });
    return authLink.concat(httpLink);
  }

  _runAuthorize() {
    if (!this.session.isAuthenticated) {
      return {};
    }
    return new Promise((success) => {
      let headers = {};
      let token = this.session.data.authenticated.token;
      headers['Authorization'] = `Bearer ${token}`;

      success({ headers });
    });
  }

  clientOptions() {
    return {
      link: this.link(),
      cache: this.cache,
    };
  }

 //...
}

Using ember-apollo-client pkg




Ember mismatch names in index.js and package.json

i have two different names in my package.json and index.js which i cannot change on both places. I am getting this error.

ember-cli: Your names in package.json and index.js should match. The addon in /Users/nrehman/Projects/copilot-seo-score currently have '@copilot/copilot-seo-score' in package.json and 'copilot-seo-score' in index.js. Until ember-cli v3.9, this error can be disabled by setting env variable EMBER_CLI_IGNORE_ADDON_NAME_MISMATCH to "true". For more information about this workaround, see: https://github.com/ember-cli/ember-cli/pull/7950.

My ember-cli version is "ember-cli": "~3.28.3"




mardi 26 octobre 2021

Connecting ember js application with react host : microfrontend

I was trying to connect different frontend tech together in a React host using microfrontend.

I managed to connect react, vue, VanillaJS application to the React host, but i am not able to wrap my head around Ember JS, since vue, Vanilla were not framekwork, it was easy to connect them using webpack ModuleFederationPlugin.

I tried searching it over internet couldn't find any help, Is it possible to connect Ember JS application to a react based host environment(using module federation) ??

If yes would like to see an example if it's available online. (github or sandbox links)




dimanche 24 octobre 2021

Building Ember app gives me error, Cannot read property 'pkg' of null

I was trying to compile a website frontend from 2015 that utilizes an old version of ember.js and node.js. The instructions state to run make build, which in turn would run ember build dist. Though when the command is ran, it gives me this error.

Cannot read property 'pkg' of null
TypeError: Cannot read property 'pkg' of null
    at Function.Addon.resolvePath (/home/pyah/pyah/client/node_modules/ember-cli/lib/models/addon.js:347:18)
    at Function.Addon.lookup (/home/pyah/pyah/client/node_modules/ember-cli/lib/models/addon.js:362:22)
    at /home/pyah/pyah/client/node_modules/ember-cli/lib/models/project.js:222:34
    at visit (/home/pyah/pyah/client/node_modules/ember-cli/lib/utilities/DAG.js:23:3)
    at DAG.topsort (/home/pyah/pyah/client/node_modules/ember-cli/lib/utilities/DAG.js:82:7)
    at Project.initializeAddons (/home/pyah/pyah/client/node_modules/ember-cli/lib/models/project.js:220:9)
    at Project.eachAddonCommand (/home/pyah/pyah/client/node_modules/ember-cli/lib/models/project.js:249:10)
    at module.exports (/home/pyah/pyah/client/node_modules/ember-cli/lib/cli/lookup-command.js:53:13)
    at CLI.<anonymous> (/home/pyah/pyah/client/node_modules/ember-cli/lib/cli/cli.js:36:26)
    at $$$internal$$tryCatch (/home/pyah/pyah/client/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:490:16)

This error is shown even if just ember is ran in terminal.

Node.js version: v6.12.0

npm version: 6.14.15