0.44.3 • Published 6 years ago

graphql-spotify v0.44.3

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

GraphQL Spotify: Spotify API GraphQL Schema and Resolvers Built with GraphQL.js

npm.io npm version

Refer to src/schema/RootQuery.js for operations currently supported.

**Deployed Example App Powered By GraphQL Spotify** And Its Source Code

Getting started

import { makeSchema } from "graphql-spotify"
let token;
//... somewhere the Spotify token is gotten from the context
const schema = makeSchema(token)
// pass the schema to your favorite server that accepts GraphQL.js Schemas

Make sure the token obtained has the correct scope, certain queries and mutations require different scopes from Spotify

Getting started with apollo-server-express

npm install --save graphql dataloader graphql-tools isomorphic-fetch body-parser apollo-server-express express graphql-spotify

ES6
import { makeSchema } from "graphql-spotify";
import { graphqlExpress } from 'apollo-server-express';
import express from 'express';
import bodyParser from 'body-parser'
// Initialize the app
const port = parseInt(process.env.PORT, 10) || 3000
const app = express();
// bodyParser is needed just for POST.
app.use(
    '/graphql',
    bodyParser.json(),
    graphqlExpress(req => {
        let token;
        //... somewhere the spotify token is gotten from the context
        const schema = makeSchema(token)
        return { schema }
    }));
// GraphiQL, a visual editor for queries
app.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql' }));
app.listen(port, (err) => {
    if (err) throw err
    console.log(`> Ready on http://localhost:${port}/graphql`)
})
ES5
const makeSchema = require("graphql-spotify").makeSchema;
const graphqlExpress = require('apollo-server-express').graphqlExpress;
const express = require('express');
const bodyParser = require('body-parser')
// Initialize the app
const port = parseInt(process.env.PORT, 10) || 3000
const app = express();
// bodyParser is needed just for POST.
app.use(
    '/graphql',
    bodyParser.json(),
    graphqlExpress(req => {
        let token;
        //... somewhere the spotify token is gotten from the context
        const schema = makeSchema(token)
        return { schema }
    }));
// GraphiQL, a visual editor for queries
app.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql' }));
app.listen(port, (err) => {
    if (err) throw err
    console.log(`> Ready on http://localhost:${port}/graphql`)
})

Contribute

Anyone is welcome! Take a look at Roadmap.md for PR ideas and file some issues!

Used By

Created By

Sitian Liu

0.44.3

6 years ago

0.44.0

6 years ago

0.43.0

6 years ago

0.4.35

6 years ago

0.4.31

6 years ago

0.4.3

6 years ago

0.4.22

6 years ago

0.4.21

6 years ago

0.4.2

6 years ago

0.4.15

6 years ago

0.4.141

6 years ago

0.4.14

6 years ago

0.4.13

6 years ago

0.4.12

6 years ago

0.4.11

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago