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 list

  • List - 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 list

  • PastDate - Selects a date up to N days into the past, where N is the first and only value in the list

  • Email - A mocked email address

  • FirstName - A first name

  • LastName - A last name

  • Phone - A phone number

  • SSN - A mocked US social security number

  • City - A mocked city

  • Country - A random country

  • CountryCode - A random country code (ISO 3166-1 alpha-2)

  • Latitude - A random latitude

  • Longitude - A random longitude

  • Zip - A mocked US five digit zip code

  • UUID - A random UUID

  • DomainName - A mocked domain name

  • DomainSuffix - 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 URL

  • Username - A mocked username

  • CreditCard - 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