Closed trompx closed 3 years ago
Hey so sorry for missing the question.
I will open source the server but not anytime soon. I used @benzene/http
and @benzene/ws
in the API server.
I don't use type-graphql
but writing the schema in SDL with graphql-tools
and generate the TypeScript definitions for resolvers using GraphQL code generator
GraphQL code generator urql plugin is also used to generate the TS in the frontend. Also I no longer used benzene-ws-client
but the client from https://github.com/enisdenjo/graphql-ws since @benzene/ws
now use the new WebSocket spec https://github.com/graphql/graphql-over-http/pull/140
Thanks a lot for the useful info @hoangvvo, really appreciate!! I still didn't have the time to implement subscriptions with urql in my app, but I'll give benzene a try when I'll have some time.
Hey @hoangvvo, do you mind just giving a hint what your paginated query response type looks like server side? I first implemented react query where I could pass response like:
query EntitiesPaginated($page: Int, $pageSize: Int) {
entitiesPaginated(page: $page, pageSize: $pageSize) {
page
nextPage
items {
...Entity
}
}
}
But in URQL, the only way to make it work with cache resolvers simplePagination is to return only the entities like:
query EntitiesPaginated($page: Int, $pageSize: Int) {
entitiesPaginated(page: $page, pageSize: $pageSize) {
...Entity
}
}
Was wondering if that is what you are doing? (as it doesn't seem you're using relay pagination).
Hey @trompx
I used simplePagination:
query messages($id: ID!, $offset: Int, $limit: Int) {
messages(id: $id, offset: $offset, limit: $limit) {
...MessageParts
}
}
fragment MessageParts on Message {
id
creatorId
createdAt
text
type
}
https://github.com/hoangvvo/stereo-web/blob/main/src/components/Message/Messenger.tsx#L156
But at some places I use a custom pagination that is pretty similar to simple pagination, with the only difference is that instead of offset
I use next
which can be an id. I used MongoDB in the backend, which allows me to query something like $before: someId
.
query stories($id: ID!, $next: String, $limit: Int!) {
stories(id: $id, next: $next, limit: $limit) {
id
...StoryDetailParts
}
}
fragment StoryDetailParts on Story {
text
image
createdAt
isPublic
isLive
creatorId
queueable
}
https://github.com/hoangvvo/stereo-web/blob/main/src/components/Story/StoryFeed.tsx#L85
Hey @hoangvvo,
Thanks for open sourcing this project. I'm impressed by the benchmark of benzene but cannot really find a complete setup with a backend codebase (like you did for you nexjs-mongodb-app).
Do you plan to open source also the servers : websocket and API ? If not do you mind just sharing what server you used to play well with benzene-ws-client ? And what do you use server side for the graphql part (apollo-server or something else) ?
I have a project where I use typeORM + type-graphql + apollo-server + postgresql and was wondering if it could connect easily with your urql + benzene frontend setup.