本文整理匯總了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,
});
}