Skip to content

mathieucaroff/derpibooru-graphql

Repository files navigation

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
git clone ...
cd ...
  1. Install dependencies

With yarn:

yarn install
yarn tsc
yarn playground

With npm:

npm install
npm run compile
npm run playground
  1. Go to localhost:4000/playground

  2. 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:

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)

About

A GraphQL overlay on the Derpibooru REST API

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published