Giter VIP home page Giter VIP logo

Comments (12)

jaydenseric avatar jaydenseric commented on May 22, 2024 1

Sorry thats a yes! Instead of reinventing the wheel here and across all the other http link packages, we will have an Apollo maintained package of helpers to use for most of the implementation.

from apollo-upload-client.

jaydenseric avatar jaydenseric commented on May 22, 2024

I'm not sure. Doesn't it just replace the query with a hash?

from apollo-upload-client.

mxstbr avatar mxstbr commented on May 22, 2024

Yeah it should, but I'm still seeing the full query being sent over the wire all the time!

from apollo-upload-client.

mxstbr avatar mxstbr commented on May 22, 2024

Here are the changes I've made:

  1. Added a persisted query store to Engine:
new Engine({
   engineConfig: {
+    stores: [
+      {
+        name: 'pq',
+        inMemory: {
+          cacheSize: '5000000',
+        },
+      },
+    ],
+    persistedQueries: {
+      store: 'pq',
+    },
   },
 });
  1. Added apollo-link-persisted-queries:
+ import { createPersistedQueryLink } from 'apollo-link-persisted-queries';
 
- const httpLink = createUploadLink({ /* ...  */ });
+ const httpLink = createPersistedQueryLink().concat(
+   createUploadLink({ /* ... */ })
+ );

Then I open my frontend and look in the dev tools, and what I see is this:

screen shot 2018-02-07 at 11 48 21

Every single API request still sends the entire query text to the server 😕 /cc @jbaxleyiii

from apollo-upload-client.

jbaxleyiii avatar jbaxleyiii commented on May 22, 2024

@mxstbr @jaydenseric ah yes! Here is the solution that will need to be implemented in the upload client:

The persisted query link sets a couple items on the context (https://github.com/apollographql/apollo-link-persisted-queries/blob/master/src/index.ts#L128-L131). These are used to tell downstream network (ws, upload, http) that we want to not send the operation, but instead send the extensions.

Network links can then read them and do this and this to attach the payload correctly.

Happy to help with any questions!

from apollo-upload-client.

jbaxleyiii avatar jbaxleyiii commented on May 22, 2024

@jaydenseric also, I'm wondering if you could implement the upload portion of this library as a custom fetcher for http-link that way you don't have to keep things in sync?

https://www.apollographql.com/docs/link/links/http.html#custom

from apollo-upload-client.

jaydenseric avatar jaydenseric commented on May 22, 2024

@jbaxleyiii I think that might not work, because the File and FileList instances in variables would have been lost when the request body was JSON encoded.

from apollo-upload-client.

mxstbr avatar mxstbr commented on May 22, 2024

@jaydenseric can we add support for persisted queries anyways by adding those options to the context, even if it can't be a custom fetcher?

from apollo-upload-client.

jaydenseric avatar jaydenseric commented on May 22, 2024

The way forward is to use apollo-link-utilities once it has stabilised in this PR.

from apollo-upload-client.

mxstbr avatar mxstbr commented on May 22, 2024

Is that a yes or a no? 😆

from apollo-upload-client.

mxstbr avatar mxstbr commented on May 22, 2024

Oh I see, thanks! Can't wait ✨

from apollo-upload-client.

jaydenseric avatar jaydenseric commented on May 22, 2024

@mxstbr would you like to verify this works as expected with [email protected]?

from apollo-upload-client.

Related Issues (20)

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.