本文整理汇总了TypeScript中@csegames/camelot-unchained/lib/graphql/query.query函数的典型用法代码示例。如果您正苦于以下问题:TypeScript query函数的具体用法?TypeScript query怎么用?TypeScript query使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了query函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: fetchStatuses
export async function fetchStatuses() {
const res = await query<Pick<CUQuery, 'status'>>({
query: '',
namedQuery: 'statusEffects',
operationName: null,
variables: null,
}, HUDGraphQLQueryConfig());
return {
...res,
data: res.data && res.data.status ? res.data.status.statuses : [],
refetch: fetchStatuses,
};
}
示例2: fetchSkills
export async function fetchSkills(): Promise<HUDGraphQLQueryResult<Skill[]>> {
const res = await query<Pick<CUQuery, 'myCharacter'>>({
query: skillsQuery,
operationName: null,
namedQuery: null,
variables: {},
}, HUDGraphQLQueryConfig());
return {
...res,
data: res.data && res.data.myCharacter ? res.data.myCharacter.skills : [],
refetch: fetchSkills,
};
}
示例3: fetchItemDefRefs
export async function fetchItemDefRefs() {
const res = await query<Pick<CUQuery, 'game'>>({
query: itemDefRefsQuery,
operationName: null,
namedQuery: null,
variables: {},
}, HUDGraphQLQueryConfig());
return {
...res,
data: res.data && res.data.game ? res.data.game.items : [],
refetch: fetchItemDefRefs,
};
}
示例4: gqlQuery
export function gqlQuery(q: GraphQLQuery, options: RequestOptions = {}) {
const requestOptions: RequestOptions = {
headers: Object.assign({
'api-version': `${game.apiVersion}`,
'Content-Type': 'application/json',
Authorization: `Bearer ${game.accessToken}`,
characterId: game.selfPlayerState.characterID,
shardId: `${game.shardID}`,
Accept: 'application/json',
}, options.headers),
};
return query(q, {
url: game.webAPIHost + '/graphql',
requestOptions,
});
}