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

kiva / ui / 13771863327

10 Mar 2025 06:17PM UTC coverage: 46.768% (-0.008%) from 46.776%
13771863327

push

github

emuvente
feat: send all operations through stellate when wildcard is used

1173 of 2583 branches covered (45.41%)

Branch coverage included in aggregate %.

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

1663 of 3481 relevant lines covered (47.77%)

384.48 hits per line

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

0.0
/src/api/HttpLink.js
1
import { BatchHttpLink } from '@apollo/client/link/batch-http/index';
2
import { HttpLink } from '@apollo/client/link/http/index';
3
import { split } from '@apollo/client/core/index';
4

5
export default ({
6
        uri = '',
×
7
        fetch,
8
        apolloBatching,
9
        stellateDebugHeaders,
10
        stellateGraphqlUri,
11
        stellateCachedOperations,
12
}) => {
13
        // Note: we will have issues in the client and may need to check this too: uri.indexOf('stellate') > -1
14
        const onVm = uri.indexOf('vm') > -1 || uri.indexOf('local') > -1;
×
15

16
        const options = {
×
17
                uri,
18
                fetch,
19
                headers: {},
20
                credentials: 'same-origin',
21
                fetchOptions: {
22
                        // fix request blocked b/c of self-signed certificate on dev-vm.
23
                        strictSSL: !onVm,
24
                }
25
        };
26

27
        // Create a new options object for stellate
28
        const stellateOptions = {
×
29
                ...options,
30
                headers: stellateDebugHeaders ? {
×
31
                        ...options?.headers,
32
                        'gcdn-debug': 1,
33
                } : {},
34
                uri: stellateGraphqlUri ?? uri,
×
35
        };
36

37
        // Format operations list into an arrayif it's not undefined or an empty string
NEW
38
        const cachableOperations = (stellateCachedOperations && stellateCachedOperations !== '')
×
39
                ? stellateCachedOperations?.split(',') : [];
40

41
        const link = split(
×
42
                operation => {
43
                        // check to see if we have a Stellate uri available
NEW
44
                        if (!stellateGraphqlUri || cachableOperations.length === 0) {
×
45
                                return false;
×
46
                        }
47
                        // check if the operation is cachable
NEW
48
                        if ((cachableOperations.includes(operation.operationName) || cachableOperations.includes('*'))
×
49
                                // only use stellate uri if the response is ok or undefined, retry failed queries to origin instead
50
                                && operation.getContext()?.response?.ok !== false) {
51
                                // update our options if we are caching the query
52
                                options.uri = stellateGraphqlUri;
×
53
                                return true;
×
54
                        }
55
                        // use default graphql uri
56
                        return false;
×
57
                },
58
                // eslint-disable-next-line max-len
59
                (!apolloBatching ? new HttpLink(stellateOptions) : new BatchHttpLink(stellateOptions)), // function returns TRUE use this
×
60
                (!apolloBatching ? new HttpLink(options) : new BatchHttpLink(options)), // function returns FALSE use this
×
61
        );
62

63
        return link;
×
64
};
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

© 2025 Coveralls, Inc