vuex-orm / plugin-graphql

Vuex ORM persistence plugin to sync the store against a GraphQL API.
https://vuex-orm.github.io/plugin-graphql/
MIT License
227 stars 52 forks source link

Hey! Sorry, I can't figure out how to setup connection mode #106

Closed fesh-biz closed 5 years ago

fesh-biz commented 5 years ago

I had installed quasar and configured vuex-orm, but I can't get rid of nodes from queries

I keep getting this Connection Query Mode is 2 by config

This is my config of store

import Vue from 'vue'
import Vuex from 'vuex'
import VuexOrm from '@vuex-orm/core'
import VuexORMGraphQL from '@vuex-orm/plugin-graphql'

Vue.use(Vuex)

global.database = new VuexOrm.Database()
require('../models/autoloader')

VuexOrm.use(VuexORMGraphQL, {
  database,
  debug: true,
  connectionQueryMode: 'edges',
})

const store = new Vuex.Store({
  modules: {
  },

  plugins:[
    VuexOrm.install(database, {
      ConnectionMode: 3
    })
  ],

  // enable strict mode (adds overhead!)
  // for dev mode only
  strict: process.env.DEV
})

export default store

But any my changes to connectionQueryMode doesn't make any affects

packacge.json strings is

"@vuex-orm/core": "^0.31.12",
"@vuex-orm/plugin-graphql": "^1.0.0-rc.35",
phortx commented 5 years ago

That's because connectionQueryMode was deprecated with Release 1.0.0-rc.34.

You can change it now via the adapter pattern now.

However the documentation was not deployed for some reason. I've fixed that. Sorry for that! :)

simkuns commented 4 years ago

In case someone is still wondering how to set up connection mode. https://vuex-orm.github.io/plugin-graphql/guide/adapters.html#basics

// custom-adapter.js
import { DefaultAdapter, ConnectionMode } from "@vuex-orm/plugin-graphql"

export default class CustomAdapter extends DefaultAdapter {
    constructor() {
        super()
    }

    getConnectionMode() {
        return ConnectionMode.EDGES
    }

    // Your code
}
// store.js
import CustomAdapter from './custom-adapter'; 

// ...

VuexORM.use(VuexORMGraphQL, {
  database,
  adapter: new CustomAdapter(),
});