问题
How to consume GraphQL API from a Nativescript-vue application?
How to modify it for nativescript-vue?
Should vue-apollo package work directly? There are even some examples of "apollo with angular". But unfortunately I couldn't find instruction for nativescript-vue. @khalifa-gad said it works fine with nativescript core. But does it work also with nativescript-vue?
There is an complete implementation with angular.
Angular answer is:
import { NativeScriptModule } from 'nativescript-angular/nativescript.module';
import { NativeScriptHttpClientModule } from 'nativescript-angular/http-client';
import { ApolloModule, Apollo } from 'apollo-angular';
import { HttpLinkModule, HttpLink } from 'apollo-angular-link-http';
@NgModule({
imports: [
NativeScriptModule,
NativeScriptHttpClientModule, // this provides HttpClient
ApolloModule,
HttpLinkModule
]
})
export class AppModule {
constructor(
apollo: Apollo,
httpLink: HttpLink
) {
// create Apollo
apollo.create({
link: httpLink.create({ uri }),
// other options like cache
});
}
}
回答1:
Plugins work as in any other NativeScript app, but you may wonder how UI plugins work with Vue.
UI plugins work almost identically to how you'd use a NativeScript UI plugin in an Angular app.
According to the document's description plugins might work out-of-box expect for UI components which we have to register. I personally did use not vue-apollo but i hoping to work in nativescript-vue.
来源:https://stackoverflow.com/questions/60349985/how-to-integrate-apollo-with-nativescript-vue