feat(backend-github): GitHub GraphQL API support (#2456)
* add GitHub GraphQL api initial support * support mutiple backends for e2e tests - initial commit * add github backend e2e test (currently skipped), fix bugs per tests * refactor e2e tests, add fork workflow tests, support fork workflow in GraphQL api * remove log message that might contain authentication token * return empty error when commit is not found when using GraphQL (align with base class) * disable github backend tests * fix bugs introduced after rebase of GraphQL and OpenAuthoring features * test: update tests per openAuthoring changes, split tests into multiple files * fix: pass in headers for pagination requests, avoid async iterator as it requires a polyfill on old browsers * test(e2e): disable github backend tests
This commit is contained in:
committed by
Shawn Erquhart
parent
083a336ba4
commit
ece136c92e
@ -56,22 +56,24 @@ export const parseLinkHeader = flow([
|
||||
fromPairs,
|
||||
]);
|
||||
|
||||
export const getPaginatedRequestIterator = (url, options = {}, linkHeaderRelName = 'next') => {
|
||||
let req = unsentRequest.fromFetchArguments(url, options);
|
||||
const next = async () => {
|
||||
if (!req) {
|
||||
return { done: true };
|
||||
}
|
||||
export const getAllResponses = async (url, options = {}, linkHeaderRelName = 'next') => {
|
||||
const maxResponses = 30;
|
||||
let responseCount = 1;
|
||||
|
||||
let req = unsentRequest.fromFetchArguments(url, options);
|
||||
|
||||
const pageResponses = [];
|
||||
|
||||
while (req && responseCount < maxResponses) {
|
||||
const pageResponse = await unsentRequest.performRequest(req);
|
||||
const linkHeader = pageResponse.headers.get('Link');
|
||||
const nextURL = linkHeader && parseLinkHeader(linkHeader)[linkHeaderRelName];
|
||||
req = nextURL && unsentRequest.fromURL(nextURL);
|
||||
return { value: pageResponse };
|
||||
};
|
||||
return {
|
||||
[Symbol.asyncIterator]: () => ({
|
||||
next,
|
||||
}),
|
||||
};
|
||||
|
||||
const { headers = {} } = options;
|
||||
req = nextURL && unsentRequest.fromFetchArguments(nextURL, { headers });
|
||||
pageResponses.push(pageResponse);
|
||||
responseCount++;
|
||||
}
|
||||
|
||||
return pageResponses;
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ import {
|
||||
import unsentRequest from './unsentRequest';
|
||||
import {
|
||||
filterByPropExtension,
|
||||
getPaginatedRequestIterator,
|
||||
getAllResponses,
|
||||
parseLinkHeader,
|
||||
parseResponse,
|
||||
responseParser,
|
||||
@ -72,7 +72,7 @@ export {
|
||||
unsentRequest,
|
||||
filterByPropExtension,
|
||||
parseLinkHeader,
|
||||
getPaginatedRequestIterator,
|
||||
getAllResponses,
|
||||
parseResponse,
|
||||
responseParser,
|
||||
loadScript,
|
||||
|
Reference in New Issue
Block a user