Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sammwyy/astraql
Fast and easy to use GraphQL Client.
https://github.com/sammwyy/astraql
graphql graphql-api graphql-api-client graphql-client javascript nodejs typescript
Last synced: 28 days ago
JSON representation
Fast and easy to use GraphQL Client.
- Host: GitHub
- URL: https://github.com/sammwyy/astraql
- Owner: sammwyy
- License: mit
- Created: 2022-12-18T03:43:17.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2022-12-20T00:01:31.000Z (almost 2 years ago)
- Last Synced: 2024-10-10T12:43:10.274Z (28 days ago)
- Topics: graphql, graphql-api, graphql-api-client, graphql-client, javascript, nodejs, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/astraql
- Size: 73.2 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# AstraQL
Fast and easy to use GraphQL Client.
## 💻 Getting started
```shell
# With npm:
npm install astraql# With yarn:
yarn add astraql
```## 📚 Usage
### As a ES Module
```javascript
import { CacheLoader, GraphQLClient, query } from 'astraql';// Initialize client.
const client = new GraphQLClient({
endpoint: 'https://graphql.anilist.co',
// Optional authentication:
headers: {
'Authorization': 'bearer xxxxxxxxxxxx'
},
// Optional cache (in seconds)
cache: new CacheLoader({ expiresIn: 60 }),
});// Create a query.
const characterQuery = query`
Character($id: Int) {
Character(id: $id) {
id
name {
first
last
}
gender
age
}
}
`;// Send request.
client.fetch(characterQuery, { id: 128986 })
.then(console.log);
```### As CJS Module
```javascript
// If uses require function you will need to use .default
// For import in typescript, this is not required
const { GraphQLClient, query } = require('astraql').default;
```## 🤝 Contributing
Contributions, issues and feature requests are welcome!
Feel free to check [issues page](https://github.com/sammwyy/astraql/issues).## ❤️ Show your support
Give a ⭐️ if this project helped you!
Or buy me a coffeelatte 🙌🏾
[Ko-fi](https://ko-fi.com/sammwy) | [Patreon](https://patreon.com/sammwy)
## 📝 License
Copyright © 2022 [Sammwy](https://github.com/sammwyy).
This project is [MIT](LICENSE) licensed.