Coder Social home page Coder Social logo

graphql-binding-yelp's Introduction

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.

graphql-binding-yelp's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

nickarthur

graphql-binding-yelp's Issues

error in favoritebusinesses query

trying to understand the yelp example. favoritebusinesses gives me this error. any help how to fix this?

Syntax Error GraphQL request (2:313) Expected Name, found }\n\n1: query ($_term: String, $_location: String, $_country: String, $_offset: Int, $_limit: Int, $_sort_by: String, $_locale: String, $_longitude: Float, $_latitude: Float, $_categories: String, $_open_now: Boolean, $_open_at: Int, $_price: String, $_attributes: [String], $_radius: Float) {\n2: search(term: $_term, location: $_location, country: $_country, offset: $_offset, limit: $_limit, sort_by: $_sort_by, locale: $_locale, longitude: $_longitude, latitude: $_latitude, categories: $_categories, open_now: $_open_now, open_at: $_open_at, price: $_price, attributes: $_attributes, radius: $_radius) {}\n

other queries work just fine

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.