-
-
Notifications
You must be signed in to change notification settings - Fork 831
Closed
Labels
waiting-for-releaseFixed/resolved, and waiting for the next stable releaseFixed/resolved, and waiting for the next stable release
Description
Describe the bug
mergeTypeDefs from @graphql-tools/merge is failing to merge 2 directives if their comments do not match. More precisely, the comments should not be considered as a DIFF while merging those.
The error is coming from the following code block
const leaveInputs = new RegExp('(directive @w*d*)|( on .*$)', 'g');
const sameArguments = printedNode.replace(leaveInputs, '') === printedExistingNode.replace(leaveInputs, '');
if (!sameArguments) {
throw new Error(`Unable to merge GraphQL directive "${node.name.value}". \nExisting directive: \n\t${printedExistingNode} \nReceived directive: \n\t${printedNode}`);
}
To Reproduce
Please run the following test
import { mergeTypeDefs } from '@graphql-tools/merge'
it('Merges 2 schemas together with same directives', () => {
mergeTypeDefs([
`
"Comment"
directive @canonical on OBJECT | INTERFACE | INPUT_OBJECT | UNION | ENUM | SCALAR | FIELD_DEFINITION | INPUT_FIELD_DEFINITION
`,
'directive @canonical on OBJECT | INTERFACE | INPUT_OBJECT | UNION | ENUM | SCALAR | FIELD_DEFINITION | INPUT_FIELD_DEFINITION'
])
})
Expected behavior
The merging should not fail and should ignore the comments.
Environment:
- OS: MacOS
@graphql-tools/merge
- NodeJS: v14.15.2
Additional context
Metadata
Metadata
Assignees
Labels
waiting-for-releaseFixed/resolved, and waiting for the next stable releaseFixed/resolved, and waiting for the next stable release