-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
34 lines (27 loc) · 746 Bytes
/
index.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
import { gql } from 'apollo-boost';
import { Credentials, GraphQLConfig, User } from 'realm-graphql-client';
async function main() {
const credentials = Credentials.usernamePassword('USERNAME', 'PASSWORD');
try {
const user = await User.authenticate(credentials, 'https://power-9.us1.cloud.realm.io');
const config = await GraphQLConfig.create(
user,
'scryfall'
);
const client = config.createApolloClient();
// You can now query the GraphQL API
const response = await client.query({
query: gql`
query {
cards(sortBy: "name") {
name
}
}
`
});
console.log(response.data.cards);
} catch (e) {
console.error(e);
}
}
main();