samedi 2 novembre 2019

How to create a link to each document from _id?

Can someone tell me what is wrong with my router? I am working with graphql queries. I need to use _id as links in the list of "heroes". I will give the code of the main files below. Thanks in advance!

router.js

import EmberRouter from '@ember/routing/router';
import config from './config/environment';

const Router = EmberRouter.extend({
  location: config.locationType,
  rootURL: config.rootURL
});

Router.map(function() {
  this.route('heroes', function() {
    this.route('hero', { path: '/:hero_id' });
  });
  this.route('addhero');
});

export default Router;

heroes.js

import Route from '@ember/routing/route';
import { queryManager } from 'ember-apollo-client';
import gql from 'graphql-tag';

const query = gql`
  query {
    heroes {
      _id
      title
      description
      date
    }
  }
`;

export default Route.extend({
  apollo: queryManager(),
  model() {
    return this.apollo.watchQuery({ query }, 'heroes');
  }
});

heroes.hbs

<div class="container">
  
  <div class="row">
    <div class="col s11 m11 l11">
      <LinkTo @route="heroes.hero" @model=>
        <h5></h5>
      </LinkTo>
      <p></p>
    </div>
  </div>
  
</div>



Aucun commentaire:

Enregistrer un commentaire