• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rtCamp / snapwp / 14751291269

30 Apr 2025 09:26AM UTC coverage: 57.056%. Remained the same
14751291269

Pull #170

github

web-flow
Merge 7925b5ed1 into 9576cf4ad
Pull Request #170: fix: add no-cache for apollo client to allow dynamic query generation

183 of 398 branches covered (45.98%)

Branch coverage included in aggregate %.

0 of 1 new or added line in 1 file covered. (0.0%)

379 of 587 relevant lines covered (64.57%)

7.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

8.33
/packages/query/src/utils/query-generation.ts
1
import { gql } from '@apollo/client';
2
import {
3
        Kind,
4
        print,
5
        type DocumentNode,
6
        type FragmentDefinitionNode,
7
} from 'graphql';
8
import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
9

10
/**
11
 *
12
 * @param {DocumentNode} fragment A fragment
13
 * @return Fragment name
14
 */
15
const getFragmentName = ( fragment: DocumentNode ): string | null => {
1✔
16
        const fragmentDef = fragment.definitions.find(
×
17
                ( def ) => def.kind === Kind.FRAGMENT_DEFINITION
×
18
        ) as FragmentDefinitionNode | undefined;
19

20
        return fragmentDef?.name.value ?? null;
×
21
};
22

23
/**
24
 * @param {TypedDocumentNode<unknown,unknown>} fragments Fragment on RootQuery
25
 * @return query document with all fragments
26
 */
27
export function generateRootQuery(
28
        fragments: TypedDocumentNode< unknown, unknown >[]
29
): DocumentNode {
30
        return gql`
×
31
                ${ Object.values( fragments ).map( ( fragmentDoc ) => print( fragmentDoc ) ) }
×
32
                query getRoot{
33
                        ${ Object.values( fragments ).map(
34
                                ( fragmentDoc ) => `...${ getFragmentName( fragmentDoc ) }`
×
35
                        ) }
36
                }
37
        `;
38
}
39

40
/**
41
 * @param {TypedDocumentNode<unknown,unknown>} fragments fragment on RenderedTemplate
42
 * @return query document with all fragments
43
 */
44
export function generateTemplateQuery(
45
        fragments: TypedDocumentNode< unknown, unknown >[]
46
): DocumentNode {
47
        return gql`
×
48
                ${ Object.values( fragments ).map( ( fragmentDoc ) => print( fragmentDoc ) ) }
×
49
                query getTemplate($uri: String!) {
50
                        templateByUri(uri: $uri) {
51
                                ${ Object.values( fragments ).map(
NEW
52
                                        ( fragmentDoc ) => `...${ getFragmentName( fragmentDoc ) }`
×
53
                                ) }
54
                        }
55
                }
56
        `;
57
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc