File tree Expand file tree Collapse file tree
packages/app-store/salesforce Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -482,3 +482,7 @@ DATABASE_CHUNK_SIZE=
482482# Service Account Encryption Key for encrypting/decrypting service account keys
483483# You can use: `openssl rand -base64 24` to generate one
484484CALCOM_SERVICE_ACCOUNT_ENCRYPTION_KEY =
485+
486+ SALESFORCE_GRAPHQL_DELAY_MS = 500
487+ SALESFORCE_GRAPHQL_MAX_DELAY_MS = 2000
488+ SALESFORCE_GRAPHQL_MAX_RETRIES = 3
Original file line number Diff line number Diff line change 11import { Client , cacheExchange , fetchExchange } from "@urql/core" ;
2+ import { retryExchange } from "@urql/exchange-retry" ;
23
34import logger from "@calcom/lib/logger" ;
45import { safeStringify } from "@calcom/lib/safeStringify" ;
@@ -17,9 +18,27 @@ export class SalesforceGraphQLClient {
1718
1819 constructor ( { accessToken, instanceUrl } : { accessToken : string ; instanceUrl : string } ) {
1920 this . accessToken = accessToken ;
21+
22+ const exchanges = [ cacheExchange , fetchExchange ] ;
23+
24+ if (
25+ process . env . SALESFORCE_GRAPHQL_DELAY_MS &&
26+ process . env . SALESFORCE_GRAPHQL_MAX_DELAY_MS &&
27+ process . env . SALESFORCE_GRAPHQL_MAX_RETRIES
28+ ) {
29+ const retryOptions = {
30+ maxRetries : 3 ,
31+ initialDelayMs : Number ( process . env . SALESFORCE_GRAPHQL_DELAY_MS ) ,
32+ maxDelayMs : Number ( process . env . SALESFORCE_GRAPHQL_MAX_DELAY_MS ) ,
33+ randomDelay : true ,
34+ maxNumberAttempts : Number ( process . env . SALESFORCE_GRAPHQL_MAX_RETRIES ) ,
35+ } ;
36+ exchanges . push ( retryExchange ( retryOptions ) ) ;
37+ }
38+
2039 this . client = new Client ( {
2140 url : `${ instanceUrl } /services/data/${ this . version } /graphql` ,
22- exchanges : [ cacheExchange , fetchExchange ] ,
41+ exchanges,
2342 fetchOptions : ( ) => {
2443 return {
2544 headers : { authorization : `Bearer ${ this . accessToken } ` } ,
Original file line number Diff line number Diff line change 1414 "@calcom/prisma" : " workspace:*" ,
1515 "@jetstreamapp/soql-parser-js" : " ^6.1.0" ,
1616 "@jsforce/jsforce-node" : " ^3.6.3" ,
17- "@urql/core" : " ^5.1.1"
17+ "@urql/core" : " ^5.1.1" ,
18+ "@urql/exchange-retry" : " ^2.0.0"
1819 },
1920 "devDependencies" : {
2021 "@calcom/types" : " workspace:*" ,
Original file line number Diff line number Diff line change 165165 " RETELL_AI_TEST_CAL_API_KEY" ,
166166 " SALESFORCE_CONSUMER_KEY" ,
167167 " SALESFORCE_CONSUMER_SECRET" ,
168+ " SALESFORCE_GRAPHQL_DELAY_MS" ,
169+ " SALESFORCE_GRAPHQL_MAX_DELAY_MS" ,
170+ " SALESFORCE_GRAPHQL_MAX_RETRIES" ,
168171 " SAML_ADMINS" ,
169172 " SAML_CLIENT_SECRET_VERIFIER" ,
170173 " SAML_DATABASE_URL" ,
Original file line number Diff line number Diff line change @@ -5,6 +5,18 @@ __metadata:
55 version: 6
66 cacheKey: 8
77
8+ "@0no-co/graphql.web@npm:^1.0.13":
9+ version: 1.2.0
10+ resolution: "@0no-co/graphql.web@npm:1.2.0"
11+ peerDependencies:
12+ graphql: ^14.0.0 || ^15.0.0 || ^16.0.0
13+ peerDependenciesMeta:
14+ graphql:
15+ optional: true
16+ checksum: 4d5a54b93e6024b7d476e94b991e4e4ebc4ecb97e4ce886f76889741f5e419b587bedc6a00488753069534d8ae3e4de2e901ad58506ba2f74eeb8642edccc4ca
17+ languageName: node
18+ linkType: hard
19+
820"@0no-co/graphql.web@npm:^1.0.5":
921 version: 1.1.2
1022 resolution: "@0no-co/graphql.web@npm:1.1.2"
@@ -3946,6 +3958,7 @@ __metadata:
39463958 "@jsforce/jsforce-node": ^3.6.3
39473959 "@parcel/watcher": ^2.5.1
39483960 "@urql/core": ^5.1.1
3961+ "@urql/exchange-retry": ^2.0.0
39493962 graphql-config: ^5.1.3
39503963 graphql-introspection-json-to-sdl: ^1.0.3
39513964 languageName: unknown
@@ -19345,6 +19358,28 @@ __metadata:
1934519358 languageName: node
1934619359 linkType: hard
1934719360
19361+ "@urql/core@npm:^6.0.0":
19362+ version: 6.0.1
19363+ resolution: "@urql/core@npm:6.0.1"
19364+ dependencies:
19365+ "@0no-co/graphql.web": ^1.0.13
19366+ wonka: ^6.3.2
19367+ checksum: 6cedd18dc9f386d361991c6cbde61dc45c1cac9dfa9db60274fdd9acec91185d176a5c63bb39593152490f539441e226db32bdf88cfba0af4488d90399e58482
19368+ languageName: node
19369+ linkType: hard
19370+
19371+ "@urql/exchange-retry@npm:^2.0.0":
19372+ version: 2.0.0
19373+ resolution: "@urql/exchange-retry@npm:2.0.0"
19374+ dependencies:
19375+ "@urql/core": ^6.0.0
19376+ wonka: ^6.3.2
19377+ peerDependencies:
19378+ "@urql/core": ^6.0.0
19379+ checksum: a75b4bfa4cdf55f202d6e35201b2a8c3219e9d5d4660b43bc29bfecc373266f1bdd6adf1efd39566a8a3e6bdf1e8e506c17a7a598b6d4205cb5ab2d79c95ab21
19380+ languageName: node
19381+ linkType: hard
19382+
1934819383"@vercel/edge-config@npm:^0.1.1":
1934919384 version: 0.1.1
1935019385 resolution: "@vercel/edge-config@npm:0.1.1"
You can’t perform that action at this time.
0 commit comments