本文整理汇总了TypeScript中apollo-angular.Apollo.create方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Apollo.create方法的具体用法?TypeScript Apollo.create怎么用?TypeScript Apollo.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apollo-angular.Apollo
的用法示例。
在下文中一共展示了Apollo.create方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(
private apollo: Apollo,
private tokenService: TokenService,
private modalService: ModalService
) {
const uploadLink = createUploadLink({ uri: uri });
const authLink = createAuthLink(tokenService);
const errorLink = createErrorLink(modalService);
apollo.create({
link: ApolloLink.from([authLink, errorLink, uploadLink]),
cache: new InMemoryCache(),
queryDeduplication: true,
defaultOptions: {
mutate: {
errorPolicy: 'all'
},
query: {
errorPolicy: 'all'
},
watchQuery: {
errorPolicy: 'all'
}
}
});
}
示例2: constructor
constructor(apollo: Apollo, httpLink: HttpLink) {
apollo.create({
// By default, this client will send queries to the
// `/graphql` endpoint on the same host
link: httpLink.create({ uri: Meteor.absoluteUrl('/graphql') }),
cache: new InMemoryCache(),
});
}
示例3: constructor
constructor(
apollo: Apollo,
httpLink: HttpLink
) {
// create Apollo
apollo.create({
link: httpLink.create({ uri }),
cache: new InMemoryCache()
});
}
示例4: constructor
constructor(apollo: Apollo, httpLink: HttpLink) {
apollo.create({
link: middlewareLink.concat(
httpLink.create({
uri: 'https://1jzxrj179.lp.gql.zone/graphql',
}),
),
cache: new InMemoryCache(),
});
}
示例5: constructor
constructor(apollo: Apollo, httpLink: HttpLink) {
const uri = 'https://api.graph.cool/simple/v1/cjc9v2j990b9p01991mc14n8e';
const http = httpLink.create({ uri });
apollo.create({
link: http,
cache: new InMemoryCache()
});
}
示例6: constructor
constructor(apollo: Apollo, httpLink: HttpLink, ngrxCache: NgrxCache) {
apollo.create({
// By default, this client will send queries to the
// `/graphql` endpoint on the same host
link: httpLink.create({
uri: "/api"
}),
cache: ngrxCache.create({})
});
}
示例7: constructor
constructor(
apollo: Apollo,
httpLink: HttpLink
) {
const link = requestLink(
httpLink.create({
uri: environment.graphql.http,
withCredentials: true
})
);
apollo.create({
link,
cache: new InMemoryCache
});
}
示例8: constructor
constructor(
apollo: Apollo,
httpLink: HttpLink
) {
const link = requestLink(
httpLink.create({
uri: `http://${environment.url}/graphql`,
withCredentials: true,
})
);
apollo.create({
link,
cache: new InMemoryCache,
});
}
示例9: constructor
constructor(apollo: Apollo, httpLink: HttpLink) {
const http = httpLink.create({ uri: `${environment.apiAddress}/graphql` });
const middleware = setContext(() => ({
headers: new HttpHeaders().set(
'Sandwich-Auth-Token',
localStorage.getItem('token') || ''
)
}));
const error = onError(({ networkError, graphQLErrors }) => {
console.error(networkError);
window.location.pathname = '/login';
});
const link = middleware.concat(error).concat(http);
apollo.create({
link,
cache: new InMemoryCache({
dataIdFromObject: (o: any) => {
let key;
switch (o.__typename) {
case 'user':
key = `${o.__typename}-${o.userId},`;
break;
case 'week':
key = `${o.__typename}-${o.weekId},`;
break;
case 'weekUserLink':
key = `${o.__typename}-${o.weekId}-${o.userId},`;
break;
default:
key = `${o.__typename}-${o.id},`;
break;
}
return key;
}
})
});
}
示例10: constructor
constructor(apollo : Apollo, httpLink : HttpLink) {
apollo.create({
link: httpLink.create({ uri: 'http://localhost:4000/graphql'}),
cache: new InMemoryCache()
})
}