Live data from Hacker News

GraphQL: A data query language

code.facebook.com

31–40 of 84 posts

Re: GraphQL: A data query language

#31
post #28

Earlier quoted context omitted.

responsibility of the client, no? to dictate how many results to return.

Ugh.. My comment was meant in the Relay thread, but anyway, it sounds like Relay/GraphQL is designed to not fetch anything that isn't actually rendered. In my own SPA apps, I very frequently over-fetch to reduce latency. I was hoping there would be a nice compatible way to manage this use case. I'm not too familiar how this works, but maybe it's enough to query the additional data in parent component or somewhere and…

To expand on lgas' answer, you can certainly over fetch with Relay/GraphQL if your product needs to.

The intent is to prevent accidental/unintentional over or under fetching that leads to bugs or poor experiences.

Re: GraphQL: A data query language

#33

Why mirror the structure, but not syntactic details, of JSON (or YML) in the pretty printing? It's true that we've passed peak colon as a culture, and need to start reimagining life in a post-colonial way, but...

GraphQL queries are hierarchical so that the response mirrors the structure of the query. We found that there were needs of the query (query parameters and directives, for example) that didn't feel ideally represented in JSON, which is why we have a different syntax. We've got a reference lexer and parser in JS at https://github.com/graphql/graphql-js/tree/master/src/langua... , and we have a parser in C++ with C and…

Anecdote: when Relay/GraphQL were first announced, we tried to get Relay without GraphQL by writing JSON. This had some advantages (a query was a valid/renderable response!)

...but we had some really ugly JSON. It was worth it for us to get the readable syntax to just use GraphQL.

With client tooling like GraphiQL and editor plugins, it should just get better.

Re: GraphQL: A data query language

#34

Earlier quoted context omitted.

Yep, GraphQL is agnostic as to how your data is stored. For example, https://github.com/graphql/swapi-graphql/ is a GraphQL schema that is backed by the swapi.co API. The examples at https://github.com/graphql/graphql-js/blob/master/src/__test... are backed by in-memory JSON objects. At Facebook, we have GraphQL types backed by data stored in a number of backends, including types backed by SQL tables.

I'd like to read more about the backing data stores. If you're aggregating data across a lot of different stores, it seems you could easily add what looks like a tiny piece of data to your query, but, in truth, is much more expensive on the backend.

It's important to realize that you're essentially defining an API for your product. If something is expensive to access, you should either not expose it directly through your API, or add appropriate levels of caching to mitigate the costs.

Re: GraphQL: A data query language

#35
post #14

What about inequality operators (>, >=, What about complex predicates (and, or)? The language seems rather limited.

When building out a GraphQL schema, the schema developer chooses which functionality to expose to the client. So rather than having the client do operations or predicates directly, the server declares what functionality is available, and might expose functionality that ordinarily would have used operators or predicates. For example, we might have the following query on Facebook's GraphQL schema: { user(id: 4) { follo…

Any idea when this will work with Relay?

Re: GraphQL: A data query language

#36
post #13

Earlier quoted context omitted.

If you look at facebook's Relay implementation the graphql queries are indeed sent as POSTs. https://github.com/facebook/relay/blob/master/src/network-la...

Interesting. I wonder how that plays with caching. Most caches ignore POST requests.

You don't want to use the browser's cache here. You can cache the properties in a more granular way yourself. Relay will do that for you.

Re: GraphQL: A data query language

#37

Earlier quoted context omitted.

Interesting. I wonder how that plays with caching. Most caches ignore POST requests.

You don't want to use the browser's cache here. You can cache the properties in a more granular way yourself. Relay will do that for you.

Yeah, I guess I was thinking more about the server side.

Re: GraphQL: A data query language

#39

Every time there's a new post about GraphQL, I become even more concerned that "GraphQL" was the wrong name to use publicly. It seems like most people assume it's just another combination of two buzzwords, Graph and QL, and incorrectly pattern match it. In an attempt to help resolve this issue, I suggest that you think of it as ProductQL or ProductAPI instead. It's not a storage layer. It's not really a query languag…

  In an attempt to help resolve this issue, I suggest that you think of it as ProductQL or ProductAPI instead.
  
  It's not a storage layer. It's not really a query language. It's an alternative way to define an API that more closely matches the typical mental and product domains than REST.
That is a tremendous and useful insight.

Re: GraphQL: A data query language

#40

Every time there's a new post about GraphQL, I become even more concerned that "GraphQL" was the wrong name to use publicly. It seems like most people assume it's just another combination of two buzzwords, Graph and QL, and incorrectly pattern match it. In an attempt to help resolve this issue, I suggest that you think of it as ProductQL or ProductAPI instead. It's not a storage layer. It's not really a query languag…

[deleted]
Post reply on HN