Skip to content

component props are not being injected to fake instance while SSR #454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dehypnosis opened this issue Nov 27, 2018 · 1 comment
Closed

Comments

@dehypnosis
Copy link

dehypnosis commented Nov 27, 2018

It seems that props are not being injected to fake instance properly while SSR.

Here is the component.

{ name: 'ResourceBroker',
... (omitted)
  props: { brokerId: { type: [Function: String], required: true } },
  computed: { broker: [Function: broker] },
  apollo:
   { viewer: { query: [Object], variables: [Function: variables] } },
  render: { [Function: render] _withStripped: true },
  staticRenderFns: [],
  _compiled: true,
  _ssrRegister: [Function: hook],
  beforeCreate: [ [Function: hook] ],
  __file: 'src/pages/resource/broker.vue' }

The component had given attribute broker-id="1" from template.
When vue-apollo/ssr package try to prefetch the query below,

apollo: {
    viewer: {
      query: gql`
        query ($id: ID!) {
          viewer {
...omitted
          }
        }
      `,
      variables () {
        return {
          id: this.brokerId,
        }
      },
    },
  },

The variable id is evaluated as undefined.
Yes, this.brokerId is not being injected to fake instance. but this['broker-id'] has the right value ("1").

So i guess that createFakeInstance function dosen't transform kebab-cased attribute to camelCased attribute. In now, i just changed the name of prop from brokerId to id, then it works.

Wish to someone find out is this a real bug or am i doing something wrong.
Thanks.

@Akryum
Copy link
Member

Akryum commented Jan 9, 2019

See #469

@Akryum Akryum closed this as completed Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants