-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for tooling API composite request #1
Comments
@pgonzaleznetwork Had a few quick questions about how flexible we want this method to be. Can you confirm that we only would want this method to create composite requests for the tooling API? That means I can assume that we'll always hit And to follow up on that, if we can assume that we'll be using the tooling composite resource only, then can I hard code the required subrequest Method (would always be GET) and referenceId (some sort of incremented variable)? |
@brandonrwind Good questions. The client code will call the function passing a
If We already use this pattern when issuing queries against the REST API Line 36 in 698d6aa
That said, HappySoup will never (at least not any time soon) edit metadata/data in the customer's org, so we should never issue a PATCH/POST request (except for the composite request itself), so it is safe at this point to hardcode the requests to use GET. Also, what is the referenceId used for? |
@brandonrwind another thing is that the API version to use is derived from the connection object that is used to instantiate the API, i.e
This object is passed (and destructured) to the Line 9 in 698d6aa
I recommend browsing the other module https://github.com/pgonzaleznetwork/sfdc-soup/blob/master/lib/sfdc_apis/usage.js Our new function would live inside this REST API module. |
HappySoup.io uses the sfdc-soup library behind the scenes. In turn, this library uses the sfdc-happy-api library (this repo), which is a tiny wrapper around some of the API operations that HappySoup needs.
Here's an example of how
sfdc-soup
uses the rest api exposed bysfdc-happy-api
https://github.com/pgonzaleznetwork/sfdc-soup/blob/bd1827cd1eec39094a4176558faf95536babb4b5/lib/sfdc_apis/metadata-types/CustomField.js#L107
Rest API: https://github.com/pgonzaleznetwork/sfdc-happy-api/blob/main/lib/rest.js
We should build a function inside the rest API module to support a composite request.
Spec:
The function should be a closure, like all other functions inside the rest API module. This is so that the function can use the connection object that is passed to the outer function.
The function should take a list of URLs. The list can be of any size, i.e 100 URLs should be allowed. Each URL represents an endpoint that can be passed to the composite request.
Because the composite requests accepts a max of 25 URLs, the function should split the 100 (or whatever number) URLS, into batches of 25 or less (in case there are left overs). We already have similar functionality here
sfdc-happy-api/lib/rest.js
Line 173 in 698d6aa
and here
sfdc-happy-api/lib/rest.js
Line 303 in 698d6aa
Promise.all
to issue all the composite requests. So essentially we are issuing multiple composite requests at the same time, each with 25 URLs max. You can see a similar implementation ofPromise.all
heresfdc-happy-api/lib/rest.js
Line 189 in 698d6aa
The function should return an array of all the responses.
The text was updated successfully, but these errors were encountered: