Live data from Hacker News

GraphQL Working Draft

facebook.github.io

31–40 of 71 posts

Re: GraphQL Working Draft

#33

Earlier quoted context omitted.

Unlike with RESTful APIs, a server basically only needs a single endpoint that parses and responds to GraphQL commands. This isn't as far off as you suppose to be the case.

The trickiness will come in handling authentication for all the nested resources (e.g., user X can only see public photos for user Y, and can't update them) and generating efficient queries to a relational datastore. Coming up with a clean architecture for that actually seems like a fun project!

Yes, this is exactly the hard/interesting part to implement. Facebook uses their own graph databases which lets you specify access control rules. You'd need something similar on top of SQL.

Re: GraphQL Working Draft

#34

Earlier quoted context omitted.

Unlike with RESTful APIs, a server basically only needs a single endpoint that parses and responds to GraphQL commands. This isn't as far off as you suppose to be the case.

The trickiness will come in handling authentication for all the nested resources (e.g., user X can only see public photos for user Y, and can't update them) and generating efficient queries to a relational datastore. Coming up with a clean architecture for that actually seems like a fun project!

You mean handling authorization.

Re: GraphQL Working Draft

#35
post #21

Lol - the code example seems to imply that Zuckerburg's user id is 4.

As a ruby programmer, my gut reaction was that this had something to do with bugs caused by the object id of `nil` being 4. But of course that's not the case :)

Re: GraphQL Working Draft

#36
post #21

Lol - the code example seems to imply that Zuckerburg's user id is 4.

Who is 1,2,3 ?

You could always try...

  - https://www.facebook.com/1
  - https://www.facebook.com/2
  - https://www.facebook.com/3
My guess (and there may even be apocrypha about it), is that these were old registration test accounts that didn't survive the first Zuckerbergian purge.

Re: GraphQL Working Draft

#37

Earlier quoted context omitted.

GraphQL doesn't prescribe a particular approach to mutations; it allows the server developer to specify what mutations are available. For example, at Facebook we have a storyCreate mutation, and a friendRequestAdd mutation. Mutations are just top level fields, but with side effects; because they are fields, the client sends up a selection set with the mutation. This allows the client to receive whatever data it needs…

Awesome, thanks for the explanation. My team is rolling out an REST API currently and I've always wanted a Linq/SQL type of interface to REST API's. I could definitely see GraphQL evolving in that kind of direction. Some amazingly cool open source tech coming out of Facebook these days.

Maybe OData?

Re: GraphQL Working Draft

#38
post #16

Earlier quoted context omitted.

Readability I guess. The new syntax looks pretty good to me. A little heavy on the (( and )) but very obvious as to what is being asked.

I wonder how important readability is in this case, though. How likely is it that this language will be written (or read) directly by people, rather than generated and consumed by programs? The potential bugs in generators and parsers (think SQL injection) seem like a real cost, which I would have thought would outweigh the benefit of improved readability.

GraphQL is definitely designed to be written by developers, not by tools. We have a feature called query variables that provides the same strong typing to input values for queries that need to fetch different data dynamically.

Re: GraphQL Working Draft

#39
post #36

Earlier quoted context omitted.

Who is 1,2,3 ?

You could always try... - https://www.facebook.com/1 - https://www.facebook.com/2 - https://www.facebook.com/3 My guess (and there may even be apocrypha about it), is that these were old registration test accounts that didn't survive the first Zuckerbergian purge.

Correct. SQL auto increment keys plus test accounts resulted in Zuck being 4.

Re: GraphQL Working Draft

#40
post #12
post #11

Would love to see a more robust server backend for this, but I am assuming it's still a long way off. A standard is a very good start. I notice the license is BSD, but is this patent encumbered?

There's a JS server provided: https://github.com/graphql/graphql-js .

> It is not a fully standalone GraphQL server that a client developer could use to start manipulating and querying data.... The only “backend” we have targeted for this early preview are in-memory stubs in test cases.

> To that end the target audience is not the client developer, but those who have or are actively interested in building their own GraphQL implementations and tools.

I guess I'm kind of happy that FB are releasing something regarding GraphQL since introducing it in February. I just thought they got busy with React Native and forgot about everything else they hyped up back in February.

Post reply on HN