Nativescript-vue graphql后端?

问题描述 投票:2回答:1

刚刚开始尝试nativescript-vue。由于它很新,因此似乎找不到关于与graphql进行nativescript-vue集成的良好文档。尝试过vue-apollo,但无法安装。当我执行vue-apollo时,它会出错。是否有任何有关如何将nativescript-vue与graphql后端或更具体地通过vue add apollo集成的好文档?

nativescript nativescript-vue
1个回答
0
投票

我想确认nativescript-vue在vue-apollo上正常工作

您应该首先使用npm或yarn安装apollo-boost

apollo

main.ts

yarn add vue-apollo graphql apollo-boost

如果要查看某些已安装的版本。

带有本地脚本示例的Vue-Apollo:

import Vue from "nativescript-vue"; import routes from "./routes"; import store from "./store"; import * as ApplicationSettings from "tns-core-modules/application-settings"; import VueApollo from "vue-apollo"; import ApolloClient from "apollo-boost"; // GET TOKEN and Prepare for header bearer const tokenInAppSet = ApplicationSettings.getString("token") ? ApplicationSettings.getString("token").replace(/['"]+/g, "") : false; /////////////// APOLLO export const defaultClient = new ApolloClient({ uri: "http://000.com/graphql", headers: { authorization: `Bearer ${tokenInAppSet}`, } }); Vue.use(VueApollo); const apolloProvider = new VueApollo({ defaultClient, }); new Vue({ store, apolloProvider, render: (h) => h("frame", [h(tokenInAppSet ? routes.entered : routes.login)]), }).$start();

https://github.com/kaanguru/apollo-jwt

© www.soinside.com 2019 - 2024. All rights reserved.