Hacker News new | ask | show | jobs
by WhitneyLand 3406 days ago
Great project. I'm still deciding how much like gql itself.

Trying scaffold.io and found the simplest code to get the first customer is

const myQuery = gql`

{

viewer {

  allCustomers(first: 1) {
                    
   edges { node { firstName } }
               
  }
         
 }
}

client.query({ query: myQuery })

.then((graphQLResult) => {

console.log('success: ', graphQLResult.data.viewer.allCustomers.edges[0].node.firstName)

})

All this verbosity has a reason (for example to support paging), but the elegance hasn't hit me yet.

2 comments

viewer is a Relay convention for wrapping fields in an authenticated context. If the viewer does not resolve (not logged in) then data.viewer is null. It makes view permissions checking a lot easier and simpler.

Edges and node is also a Relay interface.

Graphql can be simpler if you don't use relay. Also the relay client is quite fat.

I use Apollo and I do use relay interface and conventions, just without the official Relay client. I like Apollo's simplicity a lot more.

Thanks, actually that is Apollo client, but the schema uses relay because that's what scaffold.io uses.
Hey there! This is Vince from Scaphold.io. Thanks for trying out our service. The query is as simple as it gets, but if you want to flatten the returned object, you can use recompose to flatten the returned properties.

Check it out here: https://github.com/acdlite/recompose/blob/master/docs/API.md...

Thanks Vince. A key point is that Scaphold uses Relay and it's schema on the backend, which implies the really verbose queries, and the viewer/node/edge stuff.

Yes you can use the apollo client (the code above does) but as you can see that doesn't help the query size.

For scaphold.io I think you guys have done great on a lot of things, but the docs are really failing to explain the required relay schema and concepts prominently.

For relay, I'm trying to reserve judgement. First impression is it seems like an inelegant and cumbersome design. I did read their design goals, it just seems there were better ways to achieve them. And why introduce graph theory terminology for concepts that not really new in the database world?

Anyway people should checkout scaphold.io, I think it has the best UX going for gql saas.

> And why introduce graph theory terminology for concepts that not really new in the database world?

Because it's developed by Facebook, and Facebook really does view all of their data as a graph.

I see, the classic example of tunnel vision where if you're carpenter everything looks like a nail? I hadn't thought of that reason, maybe it explains part of the rational.

But even though critique is important FB has a lot to be proud of with their leadership in open source. I know some people have qualms with the license but in general I think they've inspired other companies go more in this direction.