-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #525 from DataDog/louiszawadzki/graphql-integration
Graphql integration
- Loading branch information
Showing
21 changed files
with
1,181 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...es/core/src/rum/instrumentation/resourceTracking/graphql/__tests__/graphqlHeaders.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2016-Present Datadog, Inc. | ||
*/ | ||
|
||
import { | ||
DATADOG_GRAPH_QL_OPERATION_NAME_HEADER, | ||
DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER, | ||
DATADOG_GRAPH_QL_VARIABLES_HEADER, | ||
isDatadogCustomHeader | ||
} from '../graphqlHeaders'; | ||
|
||
describe('GraphQL custom headers', () => { | ||
it.each([ | ||
DATADOG_GRAPH_QL_OPERATION_NAME_HEADER, | ||
DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER, | ||
DATADOG_GRAPH_QL_VARIABLES_HEADER | ||
])('%s matches the custom header pattern', header => { | ||
expect(isDatadogCustomHeader(header)).toBeTruthy(); | ||
}); | ||
|
||
describe('isDatadogCustomHeader', () => { | ||
it('returns false for non-custom headers', () => { | ||
expect(isDatadogCustomHeader('non-custom-header')).toBeFalsy(); | ||
}); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
packages/core/src/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2016-Present Datadog, Inc. | ||
*/ | ||
|
||
const DATADOG_CUSTOM_HEADER_PREFIX = '_dd-custom-header'; | ||
|
||
export const DATADOG_GRAPH_QL_OPERATION_NAME_HEADER = `${DATADOG_CUSTOM_HEADER_PREFIX}-graph-ql-operation-name`; | ||
export const DATADOG_GRAPH_QL_VARIABLES_HEADER = `${DATADOG_CUSTOM_HEADER_PREFIX}-graph-ql-variables`; | ||
export const DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER = `${DATADOG_CUSTOM_HEADER_PREFIX}-graph-ql-operation-type`; | ||
|
||
export const isDatadogCustomHeader = (header: string) => { | ||
return header.match(new RegExp(`^${DATADOG_CUSTOM_HEADER_PREFIX}`)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.