apollo-server/packages/apollo-server-core
Jesse Rosenberger 18d9041db7
Don't write to persisted query cache until execution will begin. (#2227)
Since we already write to the persisted query cache asynchronously (and
intentionally do not await the Promise) this won't have any affect on the
current behavior of when the persisted query cache is written to in the
event of an executable request, but if an operation comes in and doesn't
parse or validate, we'll avoid wasting cache space on an operation that will
never execute.

Additionally, in a similar light, if a plugin throws an error which stops
execution, we can avoid the side-effect of writing to the persisted query
cache.

In terms of the APQ behavior, while this could cause additional round-trips
for a client which repeatedly sends an invalid operation, that operation is
never going to successfully finish anyway.  While developer tooling will
help avoid this problem in the first place, this refusal to store an invalid
operation in the APQ cache could actually help diagnose a failure since the
full operation (rather than just the SHA256 of that document) will appear
in the browser's dev-tools on the retry.

If we're looking to spare parsing and validating documents which we know are
going to fail, I think that's going to be a better use of the (new)
`documentStore` cache (#2111), since its in-memory and can accommodate a
more complex data structure which includes the validation errors from the
previous attempt which will, of course, be the same when validating the same
operation against the same schema again.  As the PR that introduced that
feature shows, sparing those additional parses and validations (cached APQ
documents still needs to be parsed and validated, currently) will provide a
more successful performance win overall.

Ref: https://github.com/apollographql/apollo-server/pull/2111
2019-01-25 18:01:15 +02:00
..
src Don't write to persisted query cache until execution will begin. (#2227) 2019-01-25 18:01:15 +02:00
.npmignore include readme for npm packages 2017-10-23 15:13:31 -07:00
CHANGELOG.md Apollo Server 2:Automatic Persisted Queries (#1149) 2018-06-11 15:44:20 -07:00
jest.config.js Replace {} with Object.create(null) in jest.config.js 2018-10-12 13:00:13 +02:00
package.json chore(deps): update dependency @apollographql/apollo-tools to ^0.3.0 (#2190) 2019-01-17 04:22:44 +00:00
README.md fix README badge links and test imports (#1281) 2018-07-03 10:32:02 -07:00
tsconfig.json Introduce request context and refactor pipeline code 2018-10-07 18:23:27 +02:00
tsconfig.requestPipelineAPI.json Introduce request context and refactor pipeline code 2018-10-07 18:23:27 +02:00

apollo-server-core

npm version Build Status

This is the core module of the Apollo community GraphQL Server. Read the docs. Read the CHANGELOG.