A fork of Thomas Grey's GraphQL node wrapper for the Fantasy Premier League (fantasy.premierleague.com) REST apis. Note that my caching time is reduced from 2 hours to 5 seconds and there will be other definitions and resolvers built specific for my own custom application.
npm install fpl-api-graphql --save
The package exposes GraphQL type definitions and resolvers.
const { typeDefs, resolvers } = require('fpl-api-graphql');
There are no assumptions about how this should be consumed. If serving over http this would typically be with either express-graphql or apollo-server.
This example uses express-graphql to serve and graphql-tools to build an executable schema.
The GraphQL server will be available at http://localhost:3000/graphql.
GraphiQL will be exposed at http://localhost:3000/graphiql where the api can be examined with this powerful GraphQL IDE.
const express = require('express');
const graphqlHTTP = require('express-graphql');
const { makeExecutableSchema } = require('graphql-tools');
const { typeDefs, resolvers } = require('fpl-api-graphql');
// build executable schema from typedefs and resolvers
const schema = makeExecutableSchema({ typeDefs, resolvers });
// express app
const app = express();
// graphql
app.use(
'/graphql',
graphqlHTTP({
schema,
graphiql: true,
}),
);
// serve
app.listen(3000, () => {
console.log(`express-graphql demo running on port 3000`);
});