@apollo/client 3.8.0-alpha.1 → 3.8.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/apollo-client.cjs CHANGED
@@ -1345,7 +1345,7 @@ var concat = ApolloLink.concat;
1345
1345
 
1346
1346
  var execute = ApolloLink.execute;
1347
1347
 
1348
- var version = '3.8.0-alpha.1';
1348
+ var version = '3.8.0-alpha.2';
1349
1349
 
1350
1350
  function isNodeResponse(value) {
1351
1351
  return !!value.body;
@@ -1843,6 +1843,13 @@ var createHttpLink = function (linkOptions) {
1843
1843
  credentials: context.credentials,
1844
1844
  headers: contextHeaders,
1845
1845
  };
1846
+ if (hasDirectives(['client'], operation.query)) {
1847
+ var transformedQuery = removeClientSetsFromDocument(operation.query);
1848
+ if (!transformedQuery) {
1849
+ return fromError(new Error('HttpLink: Trying to send a client-only query to the server. To send to the server, ensure a non-client field is added to the query or set the `transformOptions.removeClientFields` option to `true`.'));
1850
+ }
1851
+ operation.query = transformedQuery;
1852
+ }
1846
1853
  var _b = selectHttpOptionsAndBodyInternal(operation, print, fallbackHttpConfig, linkConfig, contextConfig), options = _b.options, body = _b.body;
1847
1854
  if (body.variables && !includeUnusedVariables) {
1848
1855
  var unusedNames_1 = new Set(Object.keys(body.variables));
@@ -4824,8 +4831,12 @@ var LocalState = (function () {
4824
4831
  }
4825
4832
  return null;
4826
4833
  };
4827
- LocalState.prototype.serverQuery = function (document) {
4828
- return removeClientSetsFromDocument(document);
4834
+ LocalState.prototype.serverQuery = function (document, options) {
4835
+ if (options === void 0) { options = Object.create(null); }
4836
+ var _a = options.removeClientFields, removeClientFields = _a === void 0 ? true : _a;
4837
+ return removeClientFields
4838
+ ? removeClientSetsFromDocument(document)
4839
+ : document;
4829
4840
  };
4830
4841
  LocalState.prototype.prepareContext = function (context) {
4831
4842
  var cache = this.cache;
@@ -5612,11 +5623,13 @@ var QueryManager = (function () {
5612
5623
  };
5613
5624
  QueryManager.prototype.transform = function (document) {
5614
5625
  var transformCache = this.transformCache;
5626
+ var _a = (this.defaultOptions.transformQuery || Object.create(null)).removeClientFields, removeClientFields = _a === void 0 ? true : _a;
5615
5627
  if (!transformCache.has(document)) {
5616
5628
  var transformed = this.cache.transformDocument(document);
5617
5629
  var noConnection = removeConnectionDirectiveFromDocument(transformed);
5618
5630
  var clientQuery = this.localState.clientQuery(transformed);
5619
- var serverQuery = noConnection && this.localState.serverQuery(noConnection);
5631
+ var serverQuery = noConnection &&
5632
+ this.localState.serverQuery(noConnection, { removeClientFields: removeClientFields });
5620
5633
  var cacheEntry_1 = {
5621
5634
  document: transformed,
5622
5635
  hasClientExports: hasClientExports(transformed),