directive @mockfn
The @mockfn
directive specifies how a field is mocked when its type utilizes the mock service.
The name
argument indicates the predefined mock function, while values
are the arguments passed to this function.
The supported functions are:
FutureDate
- Selects a date up to N days into the future, where N is the first and only value in the listList
- Selects from the list of values. The values are converted from String values into the field's type.NumberRange
- Selects a value between the first (lower) and second (upper) values in the listPastDate
- Selects a date up to N days into the past, where N is the first and only value in the listEmail
- A mocked email addressFirstName
- A first nameLastName
- A last namePhone
- A phone numberSSN
- A mocked US social security numberCity
- A mocked cityCountry
- A random countryCountryCode
- A random country code (ISO 3166-1 alpha-2)Latitude
- A random latitudeLongitude
- A random longitudeZip
- A mocked US five digit zip codeUUID
- A random UUIDDomainName
- A mocked domain nameDomainSuffix
- A random domain suffix, e.g.org
,com
IPv4Address
- A random IPv4 address as a string, e.g.140.186.32.250
IPv6Address
- A random IPv6 address as a string, e.g.2d84:26ad:91c9:b832:42b7:55e7:bf22:e737
URL
- A mocked URLUsername
- A mocked usernameCreditCard
- A mocked credit card number, e.g.2229798696491323
Currency
- A random currency name, e.g.Bahamas Dollar
CurrencyCode
- A random currency code (ISO 4217)
@mockfn
is ignored when a type is not mocked, allowing a schema to safely annotate fields with it even if mocking is only used in testing or development environments.
@mockfn
can only annotate leaf fields of object and interfaces types.
It is not allowed on any root operation type fields (fields of Query
, Mutation
and Subscription
).
Arguments
name: String
Specifies the predefined mock function
values: [JSON]
Arguments to be passed to the mock function
Locations
Type System: FIELD_DEFINITION