(api, query, variables)
| 34 | }`; |
| 35 | |
| 36 | async function gql(api, query, variables) { |
| 37 | const res = await fetch(api, { |
| 38 | method: "POST", |
| 39 | headers: { "content-type": "application/json" }, |
| 40 | body: JSON.stringify({ query, variables }), |
| 41 | }); |
| 42 | if (!res.ok) |
| 43 | throw new Error(`${api} answered ${res.status} ${res.statusText}`); |
| 44 | const body = await res.json(); |
| 45 | if (body.errors?.length) |
| 46 | throw new Error(body.errors.map((e) => e.message).join("; ")); |
| 47 | return body.data; |
| 48 | } |
| 49 | |
| 50 | export async function fetchWorld(handle, { api }) { |
| 51 | /* `user` takes a handle, `userWorld` takes the id it resolves to: the world |
no outgoing calls
no test coverage detected