Giter Club home page Giter Club logo

urql-caching's Introduction

urql-caching

im trying to understand how to implement urql caching on the server side

issues in this dummy nextjs app

  1. caching data fetched in the server side so client doesnt re-request the queries

    • there are 2 routes"/ssg" and "/ssr" which are static and server rendered pages respectively making the same query to get a user from a mock api.

    • the homepage "/" has a navbar component that has links to traverse between these 2 above routes.

    • the ssrExchange is supposed to put the data inside the urql cache and use that in client.

    • on the homepage ie "/" route it prefetches the ssg.json as it should because there is a Link and when you naviagate to "/ssr" it also fetches the ssr.json to get the data

    • on going directly to "/ssr" it makes the api call on the frontend which is a duplicate call that we are trying to avoid

    • now it could be that i made some error with implementing the exchanges or maybe with the schema or even setting up urql client im not sure

    • urql docs link for reference

    • https://formidable.com/open-source/urql/docs/advanced/server-side-rendering/

    • https://formidable.com/open-source/urql/docs/graphcache/schema-awareness/

  2. introspection queries

    • i have added a file called introspection.js to fetch the schema on the client to provide it to the exchange but im not sure how to integrate with the app which i think is the major reason caching isnt working although i did pull out the schema manually from the mock api using the networks tab and have put it inside of manual.json inside the utils folder just to make it work but it didnt
  3. app config

`

"@urql/devtools": "^2.0.3",
"@urql/exchange-execute": "^2.0.0",
"@urql/introspection": "^1.0.0",
"next": "^10.0.8",
"next-urql": "^3.0.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"urql": "^2.0.4"

`

  1. feel free to create branches and pull requests if you have a fix and thanks in advance you can view the app easily in your browser using this link https://github1s.com/prasoonchatterjee/urql-caching

urql-caching's People

Contributors

chatterjeeprasoon avatar prasoonchatterjee avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.