fix(ts): typings
This commit is contained in:
Vendored
-3
@@ -8,7 +8,4 @@ export type VueApolloComponent<V extends Vue = Vue> = VueApolloComponentOption<V
|
||||
|
||||
export class ApolloProvider {
|
||||
provide: (key?: string) => this
|
||||
prefetchAll: (context: any, components: VueApolloComponent[], options?: { includeGlobal?: boolean }) => Promise<ApolloQueryResult<any>[]>
|
||||
getStates(options?: { exportNamespace?: string }): { [key: string]: any }
|
||||
exportStates(oprions?: { globalName?: string, attachTo?: string, exportNamespace?: string}): string
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -1,6 +1,6 @@
|
||||
import './vue'
|
||||
import { VueApollo, willPrefetch } from './vue-apollo'
|
||||
import { VueApollo } from './vue-apollo'
|
||||
import { ApolloProvider } from './apollo-provider'
|
||||
|
||||
export default VueApollo
|
||||
export { willPrefetch, ApolloProvider }
|
||||
export { ApolloProvider }
|
||||
|
||||
+1
-14
@@ -4,7 +4,7 @@ import 'isomorphic-fetch'
|
||||
import { ApolloClient } from 'apollo-client'
|
||||
import { HttpLink } from 'apollo-link-http'
|
||||
|
||||
import VueApollo, { ApolloProvider } from '../index'
|
||||
import VueApollo from '../index'
|
||||
import App from './App'
|
||||
|
||||
const httpLink = new HttpLink({ uri: 'https://dummy.test.com' })
|
||||
@@ -27,16 +27,3 @@ Vue.use(VueApollo)
|
||||
|
||||
/* eslint no-new: 0 */
|
||||
new Vue({ el: '#app', provide: apolloProvider.provide(), render: h => h(App) })
|
||||
|
||||
const provider: ApolloProvider = apolloProvider
|
||||
const component = new Vue()
|
||||
|
||||
/* eslint no-unused-expressions: 0, no-return-await: 0 */
|
||||
async () => await provider.prefetchAll({ context: 'context' }, [component])
|
||||
async () => await provider.prefetchAll({ context: 'context' }, [component], { includeGlobal: false })
|
||||
|
||||
for (const key in provider.getStates()) { console.log(key) }
|
||||
for (const key in provider.getStates({ exportNamespace: 'nameSpace' })) { console.log(key) }
|
||||
|
||||
provider.exportStates().match(/js/)
|
||||
provider.exportStates({ globalName: '__APOLLO_STATE__', attachTo: 'window', exportNamespace: '' }).match(/js/)
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import { willPrefetch } from '../index'
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export default willPrefetch({
|
||||
apollo: {
|
||||
allPosts: {
|
||||
query: gql`query AllPosts {
|
||||
allPosts {
|
||||
id
|
||||
imageUrl
|
||||
description
|
||||
}
|
||||
}`,
|
||||
prefetch: true, // Don't forget this
|
||||
}
|
||||
}
|
||||
})
|
||||
Vendored
+7
-5
@@ -1,14 +1,16 @@
|
||||
import Vue from "vue";
|
||||
import { DollarApollo } from './vue-apollo';
|
||||
import Vue from 'vue'
|
||||
import { DollarApollo } from './vue-apollo'
|
||||
import { VueApolloComponentOption } from './options'
|
||||
import { ApolloProvider } from './apollo-provider';
|
||||
|
||||
declare module "vue/types/options" {
|
||||
declare module 'vue/types/options' {
|
||||
interface ComponentOptions<V extends Vue> {
|
||||
apolloProvider?: VueApolloComponentOption<V>;
|
||||
apolloProvider?: ApolloProvider
|
||||
apollo?: VueApolloComponentOption<V>
|
||||
}
|
||||
}
|
||||
|
||||
declare module "vue/types/vue" {
|
||||
declare module 'vue/types/vue' {
|
||||
interface Vue {
|
||||
$apollo: DollarApollo<any>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user