GraphQL Spotify: Spotify API GraphQL Schema and Resolvers Built with GraphQL.js
Refer to src/schema/RootQuery.js for operations currently supported.
Check out the blog on why graphql-spotify was built.
Deployed Example App Powered By GraphQL Spotify And Its Source Code Repo
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 SchemasMake sure the token obtained has the correct scope, certain queries and mutations require different scopes from Spotify
npm install --save graphql dataloader graphql-tools isomorphic-fetch body-parser apollo-server-express express graphql-spotify
import { makeSchema } from "graphql-spotify";
import { graphqlExpress, graphiqlExpress } 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`)
})const makeSchema = require("graphql-spotify").makeSchema;
const graphqlExpress = require('apollo-server-express').graphqlExpress;
const graphiqlExpress = require('apollo-server-express').graphiqlExpress;
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`)
})Anyone is welcome! Take a look at Roadmap.md for PR ideas and file some issues!