Vuex ORM GraphQL安装故障

Vuex ORM GraphQL安装故障,graphql,vuex,vuex-orm,Graphql,Vuex,Vuex Orm,我使用Laravel/graphqlapi将安装到现有的Nuxt项目中,以便尝试避免使用Apollo缓存。但在我的一个组件中,我正在运行: 从“~/data/models/Notification”导入通知; 导出默认值{ 计算:{ 通知:()=>Notification.all() }, 异步装入(){ 等待通知。fetch(); } } 但是,我收到了错误[vuex]未知操作类型:实体/通知/获取 我查看了调试日志,找到了几个可用的getter(entities/notification

我使用Laravel/graphqlapi将安装到现有的Nuxt项目中,以便尝试避免使用Apollo缓存。但在我的一个组件中,我正在运行:


从“~/data/models/Notification”导入通知;
导出默认值{
计算:{
通知:()=>Notification.all()
},
异步装入(){
等待通知。fetch();
}
}
但是,我收到了错误
[vuex]未知操作类型:实体/通知/获取

我查看了调试日志,找到了几个可用的getter(entities/notifications/query、entities/notifications/all、entities/notifications/find和entities/notifications/findIn)。我尝试在挂载的方法中运行wait Notification.all(),删除了错误,但是在Vuex中查找Notifications数据对象是空的

以下是我的其余设置:

numxt.config.js

插件:[
“~/plugins/vuex orm”,
“~/plugins/graphql”
],
插件/vuex orm.js

从“@vuex orm/core”导入VuexORM;
从“~/data/database”导入数据库;
导出默认值({store})=>{
安装(数据库)(存储);
};
插件/graphql.js

/*eslint禁用导入/no命名为默认成员*/
从“@vuex orm/core”导入VuexORM;
从“@vuex-orm/plugin-graphql”导入VuexrmGraphql;
从“阿波罗链接http”导入{HttpLink};
从“节点获取”导入获取;
从“~/data/adapter”导入CustomAdapter;
从“~/data/database”导入数据库;
//url可以是任何内容,在本例中,我们使用dotenv中的值
导出默认函数({app,env}){
const apolloClient=app?.apolloProvider?.defaultClient;
常量选项={
适配器:新的CustomAdapter(),
数据库
url:env.NUXT_env_BACKEND_API_url,
调试:process.env.NODE_env!=“生产”
};
如果(客户端){
options.apolloClient=apolloClient;
}否则{
options.link=newhttplink({uri:options.url,fetch});
}
使用(VuexORMGraphQL,选项);
};
/data/adapter.js

从'@vuex orm/plugin graphql'导入{DefaultAdapter,ConnectionMode,ArgumentMode};
导出默认类CustomAdapter扩展DefaultAdapter{
getConnectionMode(){
返回ConnectionMode.PLAIN;
}
getArgumentMode(){
返回ArgumentMode.LIST;
}
};
/data/database.js

从'@vuex orm/core'导入{Database};
//导入模型
从“~/data/models/Notification”导入通知;
从“~/data/models/User”导入用户;
const database=新数据库();
数据库。注册(用户);
数据库.登记(通知);
导出默认数据库;
/data/models/user.js

从'@vuex orm/core'导入{Model};
从“./Notification”导入通知;
导出默认类用户扩展模型{
静态实体='用户';
静态加载=['notifications'];
静态字段(){
返回{
id:this.attr(null),
电子邮件:this.string(“”),
名字:this.string(“”),
姓氏:this.string(“”),
//关系
通知:this.hasMany(通知'user\u id')
};
}
};
/data/models/notification.js

从'@vuex orm/core'导入{Model};
从“./User”导入用户;
导出默认类通知扩展模型{
静态实体='通知';
静态字段(){
返回{
id:this.attr(null),
消息:此.string(“”),
查看:this.boolean(false),
//关系
user:this.belongsTo(用户'user\u id')
};
}
};
package.json

“@vuex-orm/plugin-graphql”:“^1.0.0-rc.41”

因此,为了让这项功能正常工作,我做了一些实际有效的更改

如果其他人遇到类似的问题,下面是我所做的。。。 在我的nuxt.config.js中,将两个插件的顺序交换为:

plugins: [
    '~/plugins/graphql',
    '~/plugins/vuex-orm',
],
在我的graphql.js插件中,我重新排列了选项的顺序(首先是数据库,然后是适配器):

const options = {
  database,
  adapter: new CustomAdapter(),
  url: env.NUXT_ENV_BACKEND_API_URL,
  debug: process.env.NODE_ENV !== 'production'
};