https://github.com/serrexlabs/graphqlc
Simple GraphQL client
https://github.com/serrexlabs/graphqlc
Last synced: about 2 months ago
JSON representation
Simple GraphQL client
- Host: GitHub
- URL: https://github.com/serrexlabs/graphqlc
- Owner: serrexlabs
- Created: 2020-04-04T18:25:23.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T18:32:49.000Z (over 2 years ago)
- Last Synced: 2025-03-03T02:33:54.840Z (3 months ago)
- Language: TypeScript
- Size: 1.51 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Super simple graphql client
```ts
import { create } from './src';const client = create({
url: 'https://api.graphql.jobs/',
headers: {
Authorization: `Bearer ${token}`
}
});
interface Response {
readonly data: T;
}interface CompanyResponse {
companies: Array;
remotes: Array;
}interface Company {
name: string;
}interface Remote {
type: string;
slug: string;
}const query = `query jobs {
remotes{
type,
slug
},
companies {
name
}
}`;const fetchData = async () => {
const {
data: { companies, remotes },
} = await client.query>(query, {});
console.log(companies[0].name);
console.log(remotes[0].type);
};console.log('yooooo');
fetchData();
```