Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apollo Server 2.0 RC sends only one (error) response for unknown Batched Automatic Persisted Queries #1193

Closed
molzahn-sio opened this issue Jun 19, 2018 · 4 comments

Comments

@molzahn-sio
Copy link

Hello everyone,

we're currently trying to get batched queries (apollo-link-batch-http) to work with automatic persisted queries (apollo-link-persisted-queries) and apollo server 2.0 RC.

Our Apollo Client application is sending initially two batched requests:

[
   {
      "operationName":"LoadGeneralStatus",
      "variables":{ },
      "extensions":{
         "persistedQuery":{
            "version":1,
            "sha256Hash":"b662f1ccb162a654e1f8df1cfb43828d803bec9a24507fa0ad389dbefd7a3f99"
         }
      }
   },   {
      "operationName":"LoadControlUnits",
      "variables":{ },
      "extensions":{
         "persistedQuery":{
            "version":1,
            "sha256Hash":"393176e6a858d120f786901a6ab8fd4e1616165f14d176c8cb0a908a331e05fe"
         }
      }
   }
]

The server response is as follows:

{
   "errors":[
      {
         "message":"PersistedQueryNotFound",
         "extensions":{
            "code":"PERSISTED_QUERY_NOT_FOUND",
            "exception":{
               "stacktrace":[
                  "PersistedQueryNotFoundError: PersistedQueryNotFound",
                  "    at Object.<anonymous> (C:\\Test\\Server\\node_modules\\apollo-server-core\\src\\runHttpQuery.ts:189:16)",
                  "    at Generator.next (<anonymous>)",
                  "    at fulfilled (C:\\Test\\Server\\node_modules\\apollo-server-core\\dist\\runHttpQuery.js:4:58)",
                  "    at <anonymous>",
                  "    at process._tickDomainCallback (internal/process/next_tick.js:228:7)"
               ]
            }
         }
      }
   ]
}

Please note that there is only one response although two batched requests have been made.

Within a Query-component of React Apollo we now receive an error:

 Error: server returned results with length 1, expected length of 2
     at Object.next (webpack-internal:///./node_modules/apollo-link-batch/lib/batching.js:98:33)
     at notifySubscription (webpack-internal:///./node_modules/zen-observable/lib/Observable.js:126:18)
     at onNotify (webpack-internal:///./node_modules/zen-observable/lib/Observable.js:161:3)
     at SubscriptionObserver.next (webpack-internal:///./node_modules/zen-observable/lib/Observable.js:215:7)
     at eval (webpack-internal:///./node_modules/apollo-link-batch-http/lib/batchHttpLink.js:97:30)

I'm not completely certain, but I assume this is related to only receiving one response.

Expected behavior (as far as I understand it)

  1. Batched request with two persisted parts is beingt sent
  2. Server doesn't know about both and responds with two batched "PersistedQueryNotFound" messages
  3. Client resends the proper expanded query
  4. UI updates silently without any network errors

Note: this might somewhat be related to #941 ?

@evans
Copy link
Contributor

evans commented Jun 22, 2018

@ralmo Thank you for flagging the issue! It's definitely an bug. If you have a breaking test case, I'd love to incorporate it into the testsuite and make sure we can fix it for the next release

@molzahn-sio
Copy link
Author

@evans: glad to help. I don't have any tests into that direction, though, as I'm only just beginning to get comfortable with those advanced graphql features.

@evans
Copy link
Contributor

evans commented Jun 26, 2018

This was fixed in rc.3 🎉

@evans evans closed this as completed Jun 26, 2018
@molzahn-sio
Copy link
Author

@evans : Great, thank you very much! I can confirm that it does work as expected now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants