@salesforce/lds-bindings 1.112.0 → 1.112.1

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.
@@ -1,6 +1,6 @@
1
1
  import type { Adapter, AdapterRequestContext, ErrorResponse as LuvioErrorResponse, Luvio, Unsubscribe } from '@luvio/engine';
2
2
  import type { AstResolver } from '@luvio/graphql-parser';
3
- import type { GraphQLError } from '@luvio/lwc-luvio';
3
+ import type { GraphQLError, GraphQLInput } from '@luvio/lwc-luvio';
4
4
  import type { AdapterMetadata } from './ldsAdapter';
5
5
  interface DataResponse {
6
6
  data: any;
@@ -28,5 +28,5 @@ interface ImperativeAdapter<C> {
28
28
  * @param metadata AdapterMetadata
29
29
  * @returns Imperative adapter object with invoke and subscribe functions
30
30
  */
31
- export declare function createGraphQLImperativeAdapter<C, D>(luvio: Luvio, adapter: Adapter<C, D>, metadata: AdapterMetadata, astResolver: AstResolver): ImperativeAdapter<C>;
31
+ export declare function createGraphQLImperativeAdapter<C extends GraphQLInput, D>(luvio: Luvio, adapter: Adapter<C, D>, metadata: AdapterMetadata, astResolver: AstResolver): ImperativeAdapter<C>;
32
32
  export {};
@@ -786,15 +786,31 @@ function createInvalidConfigError() {
786
786
  function createGraphQLImperativeAdapter(luvio, adapter, metadata, astResolver) {
787
787
  const { name } = metadata;
788
788
  const imperativeAdapterInvoke = (config, requestContext, callback) => {
789
- const ast = astResolver(config.query);
790
- if (ast === undefined) {
791
- callback(createInvalidConfigError());
792
- return;
789
+ let coercedConfig = null;
790
+ if ('batchQuery' in config) {
791
+ coercedConfig = {
792
+ batchQuery: config.batchQuery.map((individualConfig) => ({
793
+ ...individualConfig,
794
+ query: astResolver(individualConfig.query),
795
+ })),
796
+ };
797
+ // If any of the configurations are invalid, we bail out of calling the adapter.
798
+ if (coercedConfig.batchQuery.some((individualConfig) => individualConfig.query === undefined)) {
799
+ callback(createInvalidConfigError());
800
+ return;
801
+ }
802
+ }
803
+ else if ('query' in config) {
804
+ const ast = astResolver(config.query);
805
+ if (ast === undefined) {
806
+ callback(createInvalidConfigError());
807
+ return;
808
+ }
809
+ coercedConfig = {
810
+ ...config,
811
+ query: ast,
812
+ };
793
813
  }
794
- const coercedConfig = {
795
- ...config,
796
- query: ast,
797
- };
798
814
  const snapshotOrPromise = adapter(coercedConfig, requestContext);
799
815
  if (snapshotOrPromise === null) {
800
816
  callback(createInvalidConfigError());
@@ -820,15 +836,31 @@ function createGraphQLImperativeAdapter(luvio, adapter, metadata, astResolver) {
820
836
  const imperativeAdapterSubscribe = (config, requestContext, callback) => {
821
837
  let subscriberCallback = callback;
822
838
  let unsub;
823
- const ast = astResolver(config.query);
824
- if (ast === undefined) {
825
- callback(createInvalidConfigError());
826
- return () => { };
839
+ let coercedConfig = null;
840
+ if ('batchQuery' in config) {
841
+ coercedConfig = {
842
+ batchQuery: config.batchQuery.map((individualConfig) => ({
843
+ ...individualConfig,
844
+ query: astResolver(individualConfig.query),
845
+ })),
846
+ };
847
+ // If any of the configurations are invalid, we bail out of calling the adapter.
848
+ if (coercedConfig.batchQuery.some((individualConfig) => individualConfig.query === undefined)) {
849
+ callback(createInvalidConfigError());
850
+ return () => { };
851
+ }
852
+ }
853
+ else if ('query' in config) {
854
+ const ast = astResolver(config.query);
855
+ if (ast === undefined) {
856
+ callback(createInvalidConfigError());
857
+ return () => { };
858
+ }
859
+ coercedConfig = {
860
+ ...config,
861
+ query: ast,
862
+ };
827
863
  }
828
- const coercedConfig = {
829
- ...config,
830
- query: ast,
831
- };
832
864
  const snapshotOrPromise = adapter(coercedConfig, requestContext);
833
865
  if (snapshotOrPromise === null) {
834
866
  subscriberCallback(createInvalidConfigError());
@@ -898,4 +930,4 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
898
930
  }
899
931
 
900
932
  export { ADAPTER_UNFULFILLED_ERROR, REFRESH_ADAPTER_EVENT, bindWireRefresh, createGraphQLImperativeAdapter, createGraphQLWireAdapterConstructor, createImperativeAdapter, createInfiniteScrollingWireAdapterConstructor, createInstrumentedAdapter, createLDSAdapter, createWireAdapterConstructor, instrument, refresh };
901
- // version: 1.112.0-725d7e6e3
933
+ // version: 1.112.1-1a0875b1d
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-bindings",
3
- "version": "1.112.0",
3
+ "version": "1.112.1",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS Bindings for SFDC",
6
6
  "main": "dist/ldsBindings.js",
@@ -31,11 +31,11 @@
31
31
  "release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-bindings"
32
32
  },
33
33
  "dependencies": {
34
- "@luvio/lwc-luvio": "0.136.5",
35
- "@salesforce/lds-graphql-parser": "^1.112.0"
34
+ "@luvio/lwc-luvio": "0.137.1",
35
+ "@salesforce/lds-graphql-parser": "^1.112.1"
36
36
  },
37
37
  "devDependencies": {
38
- "@luvio/engine": "0.136.5",
38
+ "@luvio/engine": "0.137.1",
39
39
  "@lwc/engine-core": "2.11.5"
40
40
  }
41
41
  }