From 629d3cb9a30ab00c20c8223b16349e8daff2202f Mon Sep 17 00:00:00 2001 From: Ted Tuttle <104523629+ted-faros@users.noreply.github.com> Date: Fri, 17 Feb 2023 12:34:16 -0800 Subject: [PATCH] FAI-5239: v2 flows not working (#105) --- src/graphql/graphql.ts | 10 +++++++--- test/graphql.test.ts | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/graphql/graphql.ts b/src/graphql/graphql.ts index 9f8c340..19de9c1 100644 --- a/src/graphql/graphql.ts +++ b/src/graphql/graphql.ts @@ -280,10 +280,15 @@ export function paginatedQuery(query: string): PaginatedQuery { }; } +export function paginatedQueryV2(query: string): PaginatedQuery { + return process.env.GRAPHQL_V2_PAGINATOR === 'relay' ? + paginatedWithRelayV2(query) : paginateWithOffsetLimitV2(query); +} + /** * Paginates v2 graphql queries. */ -export function paginatedQueryV2(query: string): PaginatedQuery { +export function paginatedWithRelayV2(query: string): PaginatedQuery { const edgesPath: string[] = []; const pageInfoPath: string[] = []; let firstNode = true; @@ -1077,8 +1082,7 @@ export function createNonIncrementalReaders( pageSize, graphSchema, false, - process.env.GRAPHQL_V2_PAGINATOR === 'relay' ? - paginatedQueryV2 : paginateWithOffsetLimitV2, + paginatedQueryV2, flattenV2 ); default: diff --git a/test/graphql.test.ts b/test/graphql.test.ts index 9e7f0d6..60e3d0a 100644 --- a/test/graphql.test.ts +++ b/test/graphql.test.ts @@ -169,10 +169,10 @@ describe('graphql', () => { expect(await toArray(flattenedNodes)).toMatchSnapshot(); }); - test('paginated v2 query', async () => { + test('paginated relay v2 query', async () => { const query = await loadQueryFile('commits-v2.gql'); const expectedQuery = await loadQueryFile('paginated-commits-v2.gql'); - const paginatedQuery = sut.paginatedQueryV2(query); + const paginatedQuery = sut.paginatedWithRelayV2(query); expect(paginatedQuery.edgesPath).toEqual([ 'vcs_Commit_connection', 'edges',