-
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
d619fbc
commit f3aa37a
Showing
16 changed files
with
324 additions
and
111 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
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
111 changes: 111 additions & 0 deletions
111
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,111 @@ | ||
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"', | ||
); | ||
}); | ||
|
||
it('errors on not allowed directives on system fields', () => { | ||
assertValidatorRejects( | ||
print(gql` | ||
type Root @rootEntity { | ||
id: ID @relation | ||
dummy: String | ||
} | ||
`), | ||
'Directive "@relation" is not allowed on system field "id" and will be discarded', | ||
); | ||
}); | ||
}); |
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.