本文整理汇总了TypeScript中apollo-angular-link-http.HttpLink类的典型用法代码示例。如果您正苦于以下问题:TypeScript HttpLink类的具体用法?TypeScript HttpLink怎么用?TypeScript HttpLink使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HttpLink类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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(),
});
}
示例2: constructor
constructor(
apollo: Apollo,
httpLink: HttpLink
) {
// create Apollo
apollo.create({
link: httpLink.create({ uri }),
cache: new InMemoryCache()
});
}
示例3: constructor
constructor(apollo: Apollo, httpLink: HttpLink) {
apollo.create({
link: middlewareLink.concat(
httpLink.create({
uri: 'https://1jzxrj179.lp.gql.zone/graphql',
}),
),
cache: new InMemoryCache(),
});
}
示例4: 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()
});
}
示例5: 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({})
});
}
示例6: constructor
constructor(
apollo: Apollo,
httpLink: HttpLink
) {
const link = requestLink(
httpLink.create({
uri: environment.graphql.http,
withCredentials: true
})
);
apollo.create({
link,
cache: new InMemoryCache
});
}
示例7: constructor
constructor(
apollo: Apollo,
httpLink: HttpLink
) {
const link = requestLink(
httpLink.create({
uri: `http://${environment.url}/graphql`,
withCredentials: true,
})
);
apollo.create({
link,
cache: new InMemoryCache,
});
}
示例8: createApollo
export function createApollo(httpLink: HttpLink): any {
return {
cache: new InMemoryCache(),
defaultOptions: {
query: {
errorPolicy: 'all',
fetchPolicy: 'network-only'
},
watchQuery: {
errorPolicy: 'ignore',
fetchPolicy: 'network-only'
}
},
link: httpLink.create({
uri: 'https://jetcamer.com/graphql'
})
};
}
示例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: createApollo
export function createApollo(httpLink: HttpLink) {
return {
link: httpLink.create({uri}),
cache: new InMemoryCache(),
};
}