Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update data source tutorial to use more dependable API example #31

Open
3 tasks done
jlengstorf opened this issue Oct 21, 2017 · 2 comments
Open
3 tasks done

Update data source tutorial to use more dependable API example #31

jlengstorf opened this issue Oct 21, 2017 · 2 comments

Comments

@jlengstorf
Copy link
Member

jlengstorf commented Oct 21, 2017

It turns out the IMDB API is pretty unreliable, which is a bummer. This makes it a bad choice for an example data source.

We should revamp the tutorial to use a more reliable API. Requirements are:

  • No API key required — we want people to immediately start coding, not have to sign up for API keys
  • Reliable — should be up more often than not
  • Relatively simple — if we can find a small API with one method, that would actually be the best option. A complete example that doesn’t involve a ton of copy-pasting would make the tutorial much more approachable than having to click through to GitHub for the rest of the code and/or copying hundreds of lines of code to get a proof-of-concept running

I'm currently leaning toward the xkcd API, which is small, reliable, and familiar to many developers.

@jlengstorf
Copy link
Member Author

An example xkcd response:

{
  "month": "10",
  "num": 1905,
  "link": "",
  "year": "2017",
  "news": "",
  "safe_title": "Cast Iron Pan",
  "transcript": "",
  "alt": "If you want to evenly space them, it's easiest to alternate between the Arctic and Antarctic. Some people just go to the Arctic twice, near the equinoxes so the visits are almost 6 months apart, but it's not the same.",
  "img": "https://imgs.xkcd.com/comics/cast_iron_pans.png",
  "title": "Cast Iron Pan",
  "day": "20"
}

That's a pretty straightforward schema with nothing fancy in the field resolvers. We’d basically build the link if it’s empty:

  link: data => data.link || `https://xkcd.com/${data.num}/`,

jlengstorf added a commit that referenced this issue Oct 21, 2017
This pretty much immediately needs a rewrite (see #31), but
it’s good enough for now.

close #21
jlengstorf added a commit that referenced this issue Oct 21, 2017
This pretty much immediately needs a rewrite (see #31), but
it’s good enough for now.

close #21
@jlengstorf
Copy link
Member Author

In progress here: gramps-graphql/gramps#46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant