gql-tumblr

1.1.1 • Public • Published

gql-tumblr

A GraphQL wrapper for Tumblr's API

Based on graphql-tumblr by JEstes93 with some adddons.

Dependencies:

  • graphql-js - a JavaScript GraphQL runtime.
  • tumblr.js - a JavaScript client for the Tumblr API.

Recommended additional packages:

  • express - a Fast, unopinionated, minimalist web framework for node.
  • express-graphql - Create a GraphQL HTTP server with Express.
  • body-parser - a Node.js body parsing middleware.

Installation

Install package with:

npm install gql-tumblr

or

yarn add gql-tumblr

Usage

The module returns a function which initializes Tumblr API access with a consumer/app API key and secret.

const wrapper = require('gql-tumblr')({
    consumer_key: "<your app's API key>",
    consumer_secret: "<your app's API secret>",
});

This returns an object containing two GraphQLSchemas. One is a limited schema, which excludes all endpoints which require OAuth1.0a authentication:

const LimitedSchema = require('gql-tumblr')({
    consumer_key: "<your app's API key>",
    consumer_secret: "<your app's API secret>",
}).Schemas.API_Only;

The other is a function returning a schema covering all current Tumblr API endpoints. These extra endpoints require a valid OAuth1.0a access token and secret to function correctly. These should be passed as an object, like this:

const FullSchema = require('gql-tumblr')({
    consumer_key: "<your app's API key>",
    consumer_secret: "<your app's API secret>",
}).Schemas.Full({
    token: "<a client's OAuth1.0a access token>",
    token_secret: "<a client's OAuth1.0a access token secret>",
});

Example Usage with express/express-graphql

const express = require('express');
const graphqlHTTP = require('express-graphql');
const app = express();
 
const LimitedSchema = require('gql-tumblr')({
    consumer_key: "<your app's API key>",
    consumer_secret: "<your app's API secret>",
}).Schemas.API_Only;
 
app.use('/graphql', graphqlHTTP({
    schema: LimitedSchema,
    graphiql: true
}));
 
app.listen(4000); 
// GraphiQL UI should now be available at: http://localhost:4000/graphql

Package Sidebar

Install

npm i gql-tumblr

Weekly Downloads

0

Version

1.1.1

License

MIT

Unpacked Size

158 kB

Total Files

27

Last publish

Collaborators

  • bitti