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 = 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 = consumer_key: "<your app's API key>" consumer_secret: "<your app's API secret>"SchemasAPI_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 = consumer_key: "<your app's API key>" consumer_secret: "<your app's API secret>"Schemas;
Example Usage with express/express-graphql
const express = ;const graphqlHTTP = ;const app = ; const LimitedSchema = consumer_key: "<your app's API key>" consumer_secret: "<your app's API secret>"SchemasAPI_Only; app; app; // GraphiQL UI should now be available at: http://localhost:4000/graphql