Giter Site home page Giter Site logo

graphql-tumblr's Introduction

graphql-tumblr

A GraphQL wrapper for Tumblr's API

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 graphql-tumblr

or

yarn add graphql-tumblr

Usage

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

const wrapper = require('graphql-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('graphql-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('graphql-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('graphql-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

graphql-tumblr's People

Contributors

jestes93 avatar

Watchers

 avatar  avatar

Forkers

shaungt1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.