-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.ts
78 lines (72 loc) · 1.3 KB
/
api.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { ApolloClient, InMemoryCache, gql } from '@apollo/client'
const API_URL = 'https://api.lens.dev'
/* create the API client */
export const client = new ApolloClient({
uri: API_URL,
cache: new InMemoryCache()
})
/* define a GraphQL query */
export const exploreProfiles = gql`
query ExploreProfiles {
exploreProfiles(request: { sortCriteria: MOST_PUBLICATION }) {
items {
id
name
bio
handle
picture {
... on MediaSet {
original {
url
}
}
}
stats {
totalFollowers
}
}
}
}
`
export const getProfile = gql`
query Profile($handle: Handle!) {
profile(request: { handle: $handle }) {
id
name
bio
picture {
... on MediaSet {
original {
url
}
}
}
handle
}
}
`
export const getPublications = gql`
query Publications($id: ProfileId!, $limit: LimitScalar) {
publications(request: {
profileId: $id,
publicationTypes: [POST],
limit: $limit
}) {
items {
__typename
... on Post {
...PostFields
}
}
}
}
fragment PostFields on Post {
id
metadata {
...MetadataOutputFields
}
}
fragment MetadataOutputFields on MetadataOutput {
content
}
`