Skip to content

Embed Yelp's GraphQL API into your server application

Notifications You must be signed in to change notification settings

DevanB/graphql-binding-yelp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphQL Binding for Yelp

Embed Yelp's GraphQL API into your server application

Install

yarn add graphql-binding-yelp

Example (Demo @TODO)

See example directory for full example application.

const { Yelp } = require("graphql-binding-yelp");
const { GraphQLServer } = require("graphql-yoga");
const { importSchema } = require("graphql-import");

const favoriteBusinesses = [
  { term: "Wawa", location: "Winter Garden, FL" },
  { term: "7-Eleven", location: "Winter Garden, FL" }
];

const apiKey = "__ENTER_YOUR_YELP_API_KEY__";
const yelp = new Yelp(apiKey);

const typeDefs = importSchema("schemas/app.graphql");
const resolvers = {
  Query: {
    hello: (parent, { name }) => `Hello ${name || "world!"}`,
    favoriteBusinesses: (parent, args, context, info) => {
      return Promise.all(
        favoriteBusinesses.map(args =>
          yelp.delegate("query", "search", args, context, info)
        )
      );
    }
  }
};

const server = new GraphQLServer({ resolvers, typeDefs });
server.start(() => console.log("Server running on http://localhost:4000"));

How to create a Yelp API Key

You’ll need to create a client, join the beta program, and grab the API key from your client settings.

About

Embed Yelp's GraphQL API into your server application

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published