Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upSegregation of `src/data/queries` and `src/data/types` is contra-intuitive #1443
Comments
|
Can I propose a rewrite of the example schema with graphql-tools a la #1379 (comment)? This opens up the possibility of schema stitching and I believe also solves your problem pretty easily? I'm still of the opinion that writing the schema in straight JS feels a little contra-intuitive. What is too wide is the authorization, could use a query/mutation example with some sort of access control |
|
I think so. Going off my example, I'd probably introduce dataloader for the database calls -- it sets a good example for performance reasons, including a custom JSON type could also be helpful. I'd be happy to throw a PR together for it, if even just for an example. While we're talking about it, it'd be pretty neat to be able to stitch a node-api-starter schema with RSK. Also Apollo Client 2.0 plans? |
|
@frenzzy will the feature/apollo branch need to follow suit? Those are some very interesting changes to the architecture |
|
I know that some changes are nice and unique, but it does not make sense to diverge it much.. |
|
@langpavel It's a tricky position because I only use the Apollo libs (Server, Subscriptions + Redis, Client) in production, so kinda divergent even from the Apollo branch. I could only support something like that. What would you wanna do? |
|
@tim-soft Hahaa, like same position Why? Because if you break the two, you will spend some heat on unnecessary But in fact, most of requests are first. Bots, new visitors.. almost 80 percent of traffic is NEW So, shortest pipeline is the best way how to tell arbitrary visitor arbitrary data in the shortest way. (See, less Without wasting TCP and HTTP or socket.. just ask your DB directly. My lobby |
|
The reasons why we don't want to have data layer in master branch are following:
The ASK project serves as an example of how you can use RSK with your own backend where NSK is a possible option. I think there are nginx must be configured out of the box with reverse proxy, proper caching etc. I believe that microservices architecture is the best choose for such kind of projects. We can also add examples in the future for example how to add a service for health monitoring, image resources management etc. In terms of performance I think each web app must respond with less than 50ms (TTFB) and this can not be achieved without caching, SSR is slow even without db requests. So, one internal http request for data between services will not affect performance significantly. Meanwhile I think it is ok to have the Apollo branch in RSK (or in ASK) where all in one (frontend and data layer). Just the master branch is for the majority. |
|
Ahoy @frenzzy! I appreciate your work and you teach me a lot, but I discovered RSK as best kit at the time months ago which can do all the things in harmony.
I think I developed some interesting ideas which can save time Shortest way how to speedup SSR is no cache on backend — how you can cache APIs? — No. RSK should be the fastest — as the things together do the thing in most effective way. (Sorry, nobody knows about ASK, NSK,… as I know, no reference from You can broke RSK and deploy it thousand times, sometime as API backend only, sometimes as SSR only, sometimes as the one thing, just by server config. Domain proxy will decide. but the shortcut between GraphQL and SSR can be unreproducible and only thing which is likely violated is the trend — the technical separation of concerns which is health is kept by convention. Hey sorry, I have a On the point: Segregation of
|
|
I see room for both, it's hard to check all the boxes in one boilerplate. Having it all in one app is very handy, but also having the ability to add on API endpoints(on separate servers) for high volume, computationally intensive tasks would also provide a lot of value in a generic boilerplatey sort of way. I know what I'd like to do with the Apollo branch and possibly make an Apollo+PostgresQL based NSK that can be added via schema stitching, but I'm not sure others would have the same interest ¯_(ツ)_/¯ |
|
@tim-soft Having all together as a mess is not goal of anybody |
|
Nobody likes a mess! I also have some strange use cases, like crawling/scraping which can fully consume a servers resources. You can't please everyone ;) |
|
@tim-soft Ok, I write a long essay which nobody wants read probably. So in short, All–in–one can be more maintainable than many separate one–purpose things. This is more madness than you can achieve with reasonable cumulation — see how many projects are going to monorepo — because they solve some same-thing. Like RSK in beggining. One HTTP request from start to end. I think this is true ATM too. |
|
@langpavel How would you split with care? |
|
@tim-soft Good question. |


Too wide (and falsy) segregation of GraphQL Types and Resolvers
The first example of this is
new ObjectTypeinsrc/data/queries/index.jsimporting fields.Fields should be taken in context of parent type, not as standalone information.
This can ensure some users that custom types cannot have own field resolvers which is false.
In fact, much of fields which can have own resolvers are handled level up (which is possible but not always desired) and makes thinking about GraphQL harder than it actually are.
There is place where I need collect all the opinion and experience. Please, comments are welcomed!