Queries
Some queries to get user data from our SubGraph on IPFS
Here are all the queries we use on Mintbase. This is not an exhaustive list and you can do a whole lot more, but will get you started.
Remember a Thing: metaId (Like a cup of coffee NFT) is a batch parent of tokens, so a one thing can have several tokens to it. This just means all the tokens share the same metadata (a thing). You can always find the metaId at the end of the pez-dispenser url like this one batch of dappcon tickets Q1c8y3PwYomxjW25sW3l
Earlybird Ticket
mintbase
https://thegraph.com/explorer/subgraph/nategeier/mintbase
Hosted Service
1
import { gql } from "apollo-boost";
2
3
4
export const GET_MODS = gql`
5
query tokens($id: String!, $token: String!) {
6
tokens(where: { metaId: $token, resolveOwner: $id }) {
7
id
8
}
9
}
10
`;
11
12
export const GET_ALL_STORES = gql`
13
query stores($more: Int!) {
14
stores(first: $more, where: { burned: false }) {
15
id
16
name
17
burned
18
owner
19
things(first: 1) {
20
metaId
21
}
22
}
23
}
24
`;
25
26
export const GET_STORES = gql`
27
query user($id: String!, $approver: String!) {
28
stores(where: { burned: false, owner: $id }) {
29
id
30
name
31
burned
32
boughtCount
33
valueCount
34
transferCount
35
tokenCount
36
approvers(id: $approver) {
37
id
38
}
39
}
40
}
41
`;
42
43
export const GET_STORE = gql`
44
query store($id: String!) {
45
store(id: $id, where: { burned: false }) {
46
id
47
name
48
symbol
49
totalSupply
50
things(where: { burned: false }) {
51
id
52
burned
53
forSale
54
metaId
55
tokens {
56
id
57
price
58
state
59
tokenId
60
}
61
}
62
}
63
}
64
`;
65
66
// Simply remove metaId if you just want to know if a user owns a single token
67
// from a contract
68
export const HAS_THING_FROM_STORE = gql`
69
query tokens($ownerId: String!, $metaId: String!, $storeId: String!) {
70
tokens(
71
where: { metaId: $metaId, store: $storeId, resolveOwner: $ownerId }
72
) {
73
id
74
}
75
}
76
`;
77
78
export const GET_STORE_BASIC = gql`
79
query store($id: String!, $approver: String!) {
80
store(id: $id, where: { burned: false }) {
81
id
82
name
83
symbol
84
approvers(id: $approver) {
85
id
86
}
87
}
88
}
89
`;
90
91
export const GET_ONE_STORE = gql`
92
query store($id: String!) {
93
store(id: $id, where: { burned: false }) {
94
id
95
name
96
symbol
97
totalSupply
98
things(where: { burned: false }) {
99
id
100
burned
101
forSale
102
metaId
103
tokens {
104
id
105
price
106
state
107
tokenId
108
}
109
}
110
}
111
}
112
`;
113
114
export const GET_USER_TOKENS = gql`
115
query tokens($userId: String!, $store: String!) {
116
tokens(where: { resolveOwner: $userId, store: $store, burned: false }) {
117
id
118
tokenId
119
metaId
120
state
121
}
122
}
123
`;
124
125
export const GET_THINGS = gql`
126
query store($id: String!) {
127
store(id: $id) {
128
id
129
name
130
symbol
131
totalSupply
132
things(where: { burned: false }) {
133
id
134
burned
135
forSale
136
metaId
137
tokens {
138
id
139
price
140
state
141
tokenId
142
}
143
}
144
}
145
}
146
`;
147
148
export const HAS_THING = gql`
149
query store($ownerId: String!, $metaId: String!) {
150
tokens(where: { resolveOwner: $ownerId, metaId: $metaId }) {
151
id
152
}
153
}
154
`;
155
156
export const GET_THING = gql`
157
query thing($metaId: String!) {
158
thing(id: $metaId) {
159
id
160
burned
161
forSale
162
metaId
163
minter
164
tokens {
165
id
166
price
167
state
168
tokenId
169
}
170
}
171
}
172
`;
173
174
export const GET_USER_THINGS = gql`
175
query user($account: String!) {
176
user(id: $account) {
177
id
178
tokens(first: 700) {
179
id
180
metaId
181
state
182
price
183
tokenId
184
burned
185
store {
186
id
187
burned
188
}
189
}
190
}
191
}
192
`;
193
194
export const GET_USER_STORE = gql`
195
query getStore($id: String!) {
196
user(id: $id) {
197
stores(where: { burned: false }) {
198
id
199
burned
200
}
201
}
202
}
203
`;
204
205
Copied!
Last modified 1yr ago
Copy link