-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add @hidden directive on fields
- Loading branch information
1 parent
6b45cac
commit e3e882a
Showing
14 changed files
with
277 additions
and
87 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
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
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
99 changes: 99 additions & 0 deletions
99
spec/schema/ast-validation-modules/system-field-override.spec.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,99 @@ | ||
import { print } from 'graphql'; | ||
import gql from 'graphql-tag'; | ||
import { | ||
assertValidatorAcceptsAndDoesNotWarn, | ||
assertValidatorRejects, | ||
assertValidatorWarns, | ||
} from './helpers'; | ||
|
||
describe('system field override validation', () => { | ||
it('is valid on non redundant system fields', () => { | ||
assertValidatorAcceptsAndDoesNotWarn( | ||
print(gql` | ||
type Root @rootEntity { | ||
id: ID @key | ||
createdAt: DateTime @hidden | ||
dummy: String | ||
} | ||
type Root2 @rootEntity { | ||
id: ID @hidden | ||
updatedAt: DateTime @hidden | ||
dummy: String | ||
} | ||
`), | ||
); | ||
}); | ||
|
||
it('warns on redundant system field "id"', () => { | ||
assertValidatorWarns( | ||
print(gql` | ||
type Root @rootEntity { | ||
id: ID | ||
dummy: String | ||
} | ||
`), | ||
'Manually declaring system field "id" is redundant. Either add a suitable directive or consider removing the field', | ||
); | ||
}); | ||
|
||
it('warns on redundant system field "createdAt"', () => { | ||
assertValidatorWarns( | ||
print(gql` | ||
type Root @rootEntity { | ||
createdAt: DateTime | ||
dummy: String | ||
} | ||
`), | ||
'Manually declaring system field "createdAt" is redundant. Either add a suitable directive or consider removing the field', | ||
); | ||
}); | ||
|
||
it('warns on redundant system field "updatedAt"', () => { | ||
assertValidatorWarns( | ||
print(gql` | ||
type Root @rootEntity { | ||
updatedAt: DateTime | ||
dummy: String | ||
} | ||
`), | ||
'Manually declaring system field "updatedAt" is redundant. Either add a suitable directive or consider removing the field', | ||
); | ||
}); | ||
|
||
it('errors on system field "id" type mismatch', () => { | ||
assertValidatorRejects( | ||
print(gql` | ||
type Root @rootEntity { | ||
id: String | ||
dummy: String | ||
} | ||
`), | ||
'System field "id" must be of type "ID"', | ||
); | ||
}); | ||
|
||
it('errors on system field "createdAt" type mismatch', () => { | ||
assertValidatorRejects( | ||
print(gql` | ||
type Root @rootEntity { | ||
createdAt: String | ||
dummy: String | ||
} | ||
`), | ||
'System field "createdAt" must be of type "DateTime"', | ||
); | ||
}); | ||
|
||
it('errors on system field "updatedAt" type mismatch', () => { | ||
assertValidatorRejects( | ||
print(gql` | ||
type Root @rootEntity { | ||
updatedAt: String | ||
dummy: String | ||
} | ||
`), | ||
'System field "updatedAt" must be of type "DateTime"', | ||
); | ||
}); | ||
}); |
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
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.