graphql-request#gql TypeScript Examples
The following examples show how to use
graphql-request#gql.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: hotel-collection.api.ts From master-frontend-lemoncode with MIT License | 6 votes |
getHotelCollection = async (): Promise<HotelEntityApi[]> => {
const query = gql`
query {
hotels {
id
name
shortDescription
hotelRating
address1
thumbNailUrl
}
}
`;
const { hotels } = await graphQLClient.request<GetHotelCollectionResponse>(
query
);
return hotels;
}
Example #2
Source File: licenseCheck.ts From projects-bot with MIT License | 6 votes |
export async function hasSPDXLicense (submission: ProjectSubmission): Promise<boolean> {
const ghQuery = gql`
query ($url: URI!) {
resource(url: $url) {
... on Repository {
licenseInfo {
spdxId
}
}
}
}
`
const licenseData = await ghClient.request(
ghQuery,
{ url: submission.links.source },
{ authorization: `Bearer ${process.env.GITHUB_TOKEN}` }
)
return !!(licenseData)?.resource?.licenseInfo
}
Example #3
Source File: queries.ts From homebase-app with MIT License | 6 votes |
GET_DAOS_QUERY = gql`
query getDaos($network: String!) {
daos(where: { network: { _eq: $network } }) {
dao_type {
name
}
description
address
frozen_token_id
governance_token_id
ledgers {
holder {
address
}
}
name
network
period
staked
start_level
token {
contract
decimals
is_transferable
level
name
network
should_prefer_symbol
supply
symbol
timestamp
token_id
}
}
}
`
Example #4
Source File: useSettingsMigration.ts From apps with GNU Affero General Public License v3.0 | 6 votes |
generateQuery = (settings: SettingsV2): string => {
const hasBookmarks = settings?.state?.feed?.bookmarks?.length > 0;
const hasTags =
Object.keys(settings?.state?.feed?.enabledTags ?? {}).length > 0;
const hasSources =
Object.keys(settings?.state?.feed?.disabledPublications ?? {}).length > 0;
return gql`
mutation MergeSettings(
${hasBookmarks ? `$bookmarks: AddBookmarkInput!` : ''}
${hasTags || hasSources ? `$filters: FiltersInput!` : ''}
) {
${
hasBookmarks
? `addBookmarks(data: $bookmarks) {
_
}`
: ''
}
${
hasTags || hasSources
? `feedSettings: addFiltersToFeed(filters: $filters) {
id
}`
: ''
}
}
`;
}
Example #5
Source File: subgraph.ts From ens-metadata-service with MIT License | 6 votes |
GET_DOMAINS = gql`
query getDomains($tokenId: String) {
domain(id: $tokenId) {
id
labelhash
name
parent {
id
}
resolver {
texts
}
}
}
`
Example #6
Source File: constants.ts From limit-orders-lib with GNU General Public License v3.0 | 6 votes |
GET_ORDER_BY_ID = gql`
query getOrdersByOwner($id: String) {
orders(where: { id: $id }) {
id
owner
inputToken
outputToken
minReturn
module
witness
secret
inputAmount
vault
bought
auxData
status
createdTxHash
executedTxHash
cancelledTxHash
blockNumber
createdAt
updatedAt
updatedAtBlock
updatedAtBlockHash
data
inputData
}
}
`
Example #7
Source File: helpers.ts From glide-frontend with GNU General Public License v3.0 | 6 votes |
getUserPointIncreaseEvents = async (account: string): Promise<UserPointIncreaseEvent[]> => {
try {
const { user } = await request(
GRAPH_API_PROFILE,
gql`
query getUserPointIncreaseEvents($account: ID!) {
user(id: $account) {
points {
id
campaignId
points
}
}
}
`,
{
account: account.toLowerCase(),
},
)
return user.points
} catch (error) {
return null
}
}
Example #8
Source File: subgraph.ts From nouns-monorepo with GNU General Public License v3.0 | 6 votes |
/**
* Query the subgraph and return the last auction id and bid created.
* @returns The last auction id and bid from the subgraph.
*/
export async function getLastAuctionBids(): Promise<AuctionBids> {
const res = await request<{ auctions: AuctionBids[] }>(
config.nounsSubgraph,
gql`
query {
auctions(orderBy: startTime, orderDirection: desc, first: 1) {
id
endTime
bids(orderBy: blockNumber, orderDirection: desc, first: 1) {
id
amount
bidder {
id
}
}
}
}
`,
);
return res.auctions[0];
}
Example #9
Source File: queries.ts From zora-v1-subgraph with MIT License | 6 votes |
export function mediaByIdQuery(id: string): string {
return gql`
{
media(id: "${id}") {
id
metadataURI
contentURI
contentHash
metadataHash
owner {
id
}
creator {
id
}
prevOwner {
id
}
approved {
id
}
currentBids {
id
}
currentAsk {
id
}
inactiveBids {
id
}
inactiveAsks {
id
}
}
}
`
}