Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mathieucaroff/derpibooru-graphql
A GraphQL overlay on the Derpibooru REST API
https://github.com/mathieucaroff/derpibooru-graphql
Last synced: 5 days ago
JSON representation
A GraphQL overlay on the Derpibooru REST API
- Host: GitHub
- URL: https://github.com/mathieucaroff/derpibooru-graphql
- Owner: mathieucaroff
- Created: 2019-07-14T08:28:03.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-12-11T16:19:10.000Z (almost 4 years ago)
- Last Synced: 2024-04-28T04:45:56.521Z (7 months ago)
- Language: TypeScript
- Size: 684 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Derpibooru GraphQL API
Built on top of the Rest API
## Trying out the library
These steps will allow you to run graphql in the GraphQL Playground.
1. Clone the repository
```bash
git clone ...
cd ...
```2. Install dependencies
With yarn:
```bash
yarn install
yarn tsc
yarn playground
```With npm:
```bash
npm install
npm run compile
npm run playground
```3. Go to `localhost:4000/playground`
4. Enjoy ^^
## Using the library in your project
/!\ WIP /!\ Package not yet published
Install with `npm install --save derpiboru-graphql node-fetch`
or `yarn add derpiboru-graphql node-fetch`Then use:
```js
import * as fetch from 'node-fetch'
import { DerpibooruGraphql } from 'derpibooru-graphql'let { gql, query } = new DerpibooruGraphql({ fetch })
// The recommanded way: use the gql tag //
let variables = {}
let result = await gql`
query {
search(query: "cute", per_page: 50) {
total
search {
faves
file_name
score
representations {
full
}
}
}
}
`(varialbles)console.log(result)
// If you like to have your queries in separate files, use the query function //
// let graphqlQueryText = await fs.promises.readFile('derpiboru-query.gql', 'utf-8')
let graphqlQueryText = `
query {
search(query: "cute", per_page: 50) {
total
search {
faves
file_name
score
representations {
full
}
}
}
}
`expect(await query(graphqlQueryText)).toEqual(result)
```