Skip to content

Commit 42684a8

Browse files
authored
FAI-15799: Remove relay-based Clio endpoint (#380)
1 parent 2674259 commit 42684a8

File tree

2 files changed

+0
-131
lines changed

2 files changed

+0
-131
lines changed

Diff for: src/graphql/graphql.ts

-116
Original file line numberDiff line numberDiff line change
@@ -66,129 +66,13 @@ export function isModelQuery(
6666

6767
export function paginatedQueryV2(query: string): PaginatedQuery {
6868
switch (process.env.GRAPHQL_V2_PAGINATOR) {
69-
case 'relay':
70-
return paginatedWithRelayV2(query);
7169
case 'offset-limit':
7270
return paginateWithOffsetLimitV2(query);
7371
default:
7472
return paginateWithKeysetV2(query);
7573
}
7674
}
7775

78-
/**
79-
* Paginates v2 graphql queries.
80-
*/
81-
export function paginatedWithRelayV2(query: string): PaginatedQuery {
82-
const edgesPath: string[] = [];
83-
const pageInfoPath: string[] = [];
84-
let firstNode = true;
85-
const ast = gql.visit(gql.parse(query), {
86-
Document(node) {
87-
if (node.definitions.length !== 1) {
88-
throw invalidQuery(
89-
'document should contain a single query operation definition'
90-
);
91-
}
92-
},
93-
OperationDefinition(node) {
94-
if (node.operation !== 'query') {
95-
throw invalidQuery('only query operations are supported');
96-
}
97-
98-
// Add pagination variables to query operation
99-
return createOperationDefinition(node, [
100-
['pageSize', 'Int'],
101-
['cursor', 'String'],
102-
]);
103-
},
104-
Field: {
105-
enter(node) {
106-
if (edgesPath.length) {
107-
// Skip rest of nodes once edges path has been set
108-
return false;
109-
} else if (firstNode) {
110-
firstNode = false;
111-
const newNodeName = `${node.name.value}_connection`;
112-
pageInfoPath.push(newNodeName, 'pageInfo');
113-
edgesPath.push(newNodeName, EDGES);
114-
// copy existing where args
115-
const existing = (node.arguments ?? []).filter((n) =>
116-
ALLOWED_ARG_TYPES.has(n.name.value)
117-
);
118-
return {
119-
kind: 'Field',
120-
name: {kind: 'Name', value: newNodeName},
121-
// Add pagination arguments
122-
arguments: [
123-
...existing,
124-
{
125-
kind: 'Argument',
126-
name: {kind: 'Name', value: 'first'},
127-
value: {
128-
kind: 'Variable',
129-
name: {kind: 'Name', value: 'pageSize'},
130-
},
131-
},
132-
{
133-
kind: 'Argument',
134-
name: {kind: 'Name', value: 'after'},
135-
value: {
136-
kind: 'Variable',
137-
name: {kind: 'Name', value: 'cursor'},
138-
},
139-
},
140-
],
141-
// Add pageInfo alongside the existing selection set
142-
selectionSet: {
143-
kind: 'SelectionSet',
144-
selections: [
145-
{
146-
kind: 'Field',
147-
name: {kind: 'Name', value: EDGES},
148-
selectionSet: {
149-
kind: 'SelectionSet',
150-
selections: [
151-
{
152-
kind: 'Field',
153-
name: {kind: 'Name', value: 'cursor'},
154-
},
155-
{
156-
kind: 'Field',
157-
name: {kind: 'Name', value: 'node'},
158-
selectionSet: node.selectionSet,
159-
},
160-
],
161-
},
162-
},
163-
{
164-
kind: 'Field',
165-
name: {kind: 'Name', value: 'pageInfo'},
166-
selectionSet: {
167-
kind: 'SelectionSet',
168-
selections: [
169-
{
170-
kind: 'Field',
171-
name: {kind: 'Name', value: 'hasNextPage'},
172-
},
173-
],
174-
},
175-
},
176-
],
177-
},
178-
};
179-
}
180-
return undefined;
181-
},
182-
},
183-
});
184-
185-
return {
186-
query: gql.print(ast),
187-
edgesPath,
188-
pageInfoPath,
189-
};
190-
}
191-
19276
function createOperationDefinition(
19377
node: gql.OperationDefinitionNode,
19478
varDefs: [string, string][]

Diff for: test/graphql.test.ts

-15
Original file line numberDiff line numberDiff line change
@@ -178,21 +178,6 @@ describe('graphql', () => {
178178
);
179179
});
180180

181-
test('paginated relay v2 query', async () => {
182-
const query = await loadQueryFile('commits-v2.gql');
183-
const expectedQuery = await loadQueryFile('paginated-commits-v2.gql');
184-
const paginatedQuery = sut.paginatedWithRelayV2(query);
185-
expect(paginatedQuery.edgesPath).toEqual([
186-
'vcs_Commit_connection',
187-
'edges',
188-
]);
189-
expect(paginatedQuery.pageInfoPath).toEqual([
190-
'vcs_Commit_connection',
191-
'pageInfo',
192-
]);
193-
expect(paginatedQuery.query).toEqual(expectedQuery);
194-
});
195-
196181
test('paginated offset/limit v2 query', async () => {
197182
const query = await loadQueryFile('commits-v2.gql');
198183
const paginatedQuery = sut.paginateWithOffsetLimitV2(query);

0 commit comments

Comments
 (0)