Skip to content

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

@molzahn-sio

Description

@molzahn-sio

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions