{"id":13770404,"url":"https://github.com/graphql-java/graphql-java-extended-scalars","last_synced_at":"2025-05-14T07:08:11.474Z","repository":{"id":36650571,"uuid":"151170934","full_name":"graphql-java/graphql-java-extended-scalars","owner":"graphql-java","description":"A library of extended scalars for graphql-java","archived":false,"fork":false,"pushed_at":"2025-04-21T17:12:46.000Z","size":326,"stargazers_count":272,"open_issues_count":12,"forks_count":62,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-06T20:42:15.490Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/graphql-java.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-10-01T22:48:15.000Z","updated_at":"2025-03-30T09:33:53.000Z","dependencies_parsed_at":"2023-02-13T11:16:19.978Z","dependency_job_id":"258c1dbf-623a-4a16-9be3-528044170518","html_url":"https://github.com/graphql-java/graphql-java-extended-scalars","commit_stats":{"total_commits":128,"total_committers":22,"mean_commits":5.818181818181818,"dds":0.71875,"last_synced_commit":"e7d9e3ea8873b78fb39d57e13cb0e28eb47666e1"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-java%2Fgraphql-java-extended-scalars","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-java%2Fgraphql-java-extended-scalars/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-java%2Fgraphql-java-extended-scalars/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-java%2Fgraphql-java-extended-scalars/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphql-java","download_url":"https://codeload.github.com/graphql-java/graphql-java-extended-scalars/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253585624,"owners_count":21931737,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T17:00:37.018Z","updated_at":"2025-05-14T07:08:11.448Z","avatar_url":"https://github.com/graphql-java.png","language":"Groovy","readme":"# Extended Scalars for graphql-java\n\n[![Build Status](https://github.com/graphql-java/graphql-java-extended-scalars/actions/workflows/master.yml/badge.svg)](https://github.com/graphql-java/graphql-java-extended-scalars/actions/workflows/master.yml)\n[![Latest Release](https://img.shields.io/maven-central/v/com.graphql-java/graphql-java-extended-scalars?versionPrefix=22.)](https://maven-badges.herokuapp.com/maven-central/com.graphql-java/graphql-java-extended-scalars/)\n[![Latest Snapshot](https://img.shields.io/maven-central/v/com.graphql-java/graphql-java-extended-scalars?label=maven-central%20snapshot)](https://maven-badges.herokuapp.com/maven-central/com.graphql-java/graphql-java-extended-scalars/)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-green)](https://github.com/graphql-java/graphql-java-extended-scalars/blob/master/LICENSE.md)\n\n## Overview\n\nThis library provides extended scalars for [graphql-java](https://github.com/graphql-java/graphql-java)\n\n[GraphQL Scalars](https://spec.graphql.org/draft/#sec-Scalars) are the primitive leaf values in the GraphQL type system which cannot be queried further via sub-field selections.\n\nThe GraphQL Specification defines `String`, `Int`, `Float`, `Boolean` and `ID` as well-defined [built-in scalars](https://spec.graphql.org/draft/#sec-Scalars.Built-in-Scalars) that must be present in a graphql type\nsystem. Beyond these, it is up to an implementation to decide what [custom scalars](https://spec.graphql.org/draft/#sec-Scalars.Custom-Scalars) are present.\n\nYou would use custom scalars when you want to describe more meaningful behavior or ranges of values.\n\n# Getting started\n\n## How to install\n\nTo use this library put the following into your gradle config\n\n```java\nimplementation 'com.graphql-java:graphql-java-extended-scalars:22.0'\n```\n\nor the following into your Maven config\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.graphql-java\u003c/groupId\u003e\n  \u003cartifactId\u003egraphql-java-extended-scalars\u003c/artifactId\u003e\n  \u003cversion\u003e22.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n\u003e Note:\n\u003e\n\u003e use 22.0 or above for graphql-java 22.x and above\n\u003e \n\u003e use 21.0 for graphql-java 21.x\n\u003e\n\u003e use 20.2 for graphql-java 20.x\n\u003e \n\n## How to use extended scalars\n\n### Direct use\n\nRegister the scalar with `graphql-java`\n\n```java\nRuntimeWiring.newRuntimeWiring().scalar(ExtendedScalars.DateTime)\n```\n\n### Spring for GraphQL\n\nIf you are using [Spring for GraphQL](https://docs.spring.io/spring-graphql/docs/current/reference/html/), register the scalar with `RuntimeWiringConfigurer`\n\n```java\n@Configuration\npublic class GraphQlConfig {\n    @Bean\n    public RuntimeWiringConfigurer runtimeWiringConfigurer() {\n        return wiringBuilder -\u003e wiringBuilder.scalar(ExtendedScalars.DateTime);\n    }\n}\n```\n\n### Netflix DGS\n\nNote: Netflix also wraps this library in `com.netflix.graphql.dgs:graphql-dgs-extended-scalars` for [automatic registration](https://netflix.github.io/dgs/scalars/#automatically-register-scalar-extensions-via-graphql-dgs-extended-scalars).\n\nIf you are using [Netflix DGS](https://netflix.github.io/dgs), please see the following docs:\n - [registration through runtime wiring](https://netflix.github.io/dgs/scalars/#register-scalar-extensions-via-dgsruntimewiring)\n - [configuration documentation](https://netflix.github.io/dgs/configuration/#dgs-extended-scalars-graphql-dgs-extended-scalars)\n\n## How to add extended scalars to your schema\n\nThe GraphQL Specification recommends the use of the [@specifiedBy](https://spec.graphql.org/October2021/#sec--specifiedBy) built-in schema directive to provide a scalar specification URL for specifying the behavior of custom scalar types.\n\n```graphql\ndirective @specifiedBy(url: String!) on SCALAR\n```\n\nTo use a extended scalar in your schema, define the scalar like shown below for `DateTime`\n\n```graphql\nscalar DateTime\n  @specifiedBy(url: \"https://scalars.graphql.org/andimarek/date-time.html\")\n\ntype Something {\n  someDateTime: DateTime\n}\n```\n\n# Custom Scalars\n\n## Alias Scalars\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003eScalar Definition\u003c/td\u003e\n\u003ctd\u003eDescription\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003e\nscalar AliasedScalar\n\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eYou can create aliases for existing scalars to add more semantic meaning to them.\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nFor example a link to a social media post could be representing by a `String` but the name `SocialMediaLink` is a\nmore semantically meaningful name for that scalar type.\n\nFor example, you would build it like this:\n\n```java\nAliasedScalar socialMediaLink = ExtendedScalars.newAliasedScalar(\"SocialMediaLink\")\n        .aliasedScalar(Scalars.GraphQLString)\n        .build()\n```\n\nAnd use it in a SDL schema like this :\n\n```graphql\ntype Customer {\n  name: String\n  socialMediaLink: SocialMediaLink\n}\n```\n\n## Date \u0026 Time Scalars\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003eScalar Definition\u003c/td\u003e\n\u003ctd\u003eDescription\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003e\nscalar DateTime\n  @specifiedBy(url: \n    \"https://scalars.graphql.org/andimarek/date-time.html\"\n  )\n\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eA RFC-3339 compliant date time scalar that accepts string values like \u003ccode\u003e1996-12-19T16:39:57-08:00\u003c/code\u003e and produces \u003ccode\u003ejava.time.OffsetDateTime\u003c/code\u003e objects at runtime.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003e\nscalar Date\n  @specifiedBy(url: \n    \"https://tools.ietf.org/html/rfc3339\"\n  )\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eA RFC-3339 compliant date scalar that accepts string values like \u003ccode\u003e1996-12-19\u003c/code\u003e and produces \u003ccode\u003ejava.time.LocalDate\u003c/code\u003e objects at runtime.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003e\nscalar Time\n  @specifiedBy(url: \n    \"https://tools.ietf.org/html/rfc3339\"\n  )\n\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eA RFC-3339 compliant time scalar that accepts string values like \u003ccode\u003e16:39:57-08:00\u003c/code\u003e and produces \u003ccode\u003ejava.time.OffsetTime\u003c/code\u003e objects at runtime.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003e\nscalar LocalTime\n\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003e24-hour clock time string in the format \u003ccode\u003ehh:mm:ss.sss\u003c/code\u003e or \u003ccode\u003ehh:mm:ss\u003c/code\u003e if partial seconds is zero and produces \u003ccode\u003ejava.time.LocalTime\u003c/code\u003e objects at runtime.\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nAn example declaration in SDL might be:\n\n```graphql\ntype Customer {\n  birthDay: Date\n  workStartTime: Time\n  bornAt: DateTime\n}\n\ntype Query {\n  customers(bornAfter: DateTime): [Customers]\n}\n```\n\nAnd example query might look like:\n\n```graphql\nquery {\n  customers(bornAfter: \"1996-12-19T16:39:57-08:00\") {\n    birthDay\n    bornAt\n  }\n}\n```\n\n## ID Scalars\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003eScalar Definition\u003c/td\u003e\n\u003ctd\u003eDescription\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003e\nscalar UUID\n  @specifiedBy(url: \n    \"https://tools.ietf.org/html/rfc4122\"\n  )\n\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eA universally unique identifier scalar that accepts uuid values like \u003ccode\u003e2423f0a0-3b81-4115-a189-18df8b35e8fc\u003c/code\u003e and produces \u003ccode\u003ejava.util.UUID\u003c/code\u003e instances at runtime.\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n## Numeric Scalars\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003eScalar Definition\u003c/td\u003e\n\u003ctd\u003eDescription\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003escalar PositiveInt\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eAn \u003ccode\u003eInt\u003c/code\u003e scalar that MUST be greater than zero.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003escalar NegativeInt\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eAn \u003ccode\u003eInt\u003c/code\u003e scalar that MUST be less than zero.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003escalar NonPositiveInt\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eAn \u003ccode\u003eInt\u003c/code\u003e scalar that MUST be less than or equal to zero.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003escalar NonNegativeInt\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eAn \u003ccode\u003eInt\u003c/code\u003e scalar that MUST be greater than or equal to zero.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003escalar PositiveFloat\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eAn \u003ccode\u003eFloat\u003c/code\u003e scalar that MUST be greater than zero.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003escalar NegativeFloat\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eAn \u003ccode\u003eFloat\u003c/code\u003e scalar that MUST be less than zero.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003escalar NonPositiveFloat\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eAn \u003ccode\u003eFloat\u003c/code\u003e scalar that MUST be less than or equal to zero.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003escalar NonNegativeFloat\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eAn \u003ccode\u003eFloat\u003c/code\u003e scalar that MUST be greater than or equal to zero.\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nThe numeric scalars are derivations of the standard GraphQL `Int` and `Float` scalars that enforce range limits.\n\nAn example declaration in SDL might be:\n\n```graphql\ntype Customer {\n  name: String\n  currentHeight: PositiveInt\n  weightLossGoal: NonPositiveInt\n  averageWeightLoss: NegativeFloat\n}\n\ntype Query {\n  customers(height: PositiveInt): [Customers]\n}\n```\n\nAnd example query might look like:\n\n```graphql\nquery {\n  customers(height: 182) {\n    name\n    height\n    weightLossGoal\n  }\n}\n```\n\n## Java Primitives\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003eScalar Definition\u003c/td\u003e\n\u003ctd\u003eDescription\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003escalar GraphQLLong\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eA scalar which represents \u003ccode\u003ejava.lang.Long\u003ccode\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003escalar GraphQLShort\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eA scalar which represents \u003ccode\u003ejava.lang.Short\u003ccode\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003escalar GraphQLByte\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eA scalar which represents \u003ccode\u003ejava.lang.Byte\u003ccode\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003escalar GraphQLBigDecimal\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eA scalar which represents \u003ccode\u003ejava.math.BigDecimal\u003ccode\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003escalar GraphQLBigInteger\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eA scalar which represents \u003ccode\u003ejava.math.BigInteger\u003ccode\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003escalar GraphQLChar\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eA scalar which represents \u003ccode\u003ejava.lang.Character\u003ccode\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n## Locale Scalar\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003eScalar Definition\u003c/td\u003e\n\u003ctd\u003eDescription\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003e\nscalar Locale\n  @specifiedBy(url: \n    \"https://tools.ietf.org/html/bcp47\"\n  )\n\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eThe Locale scalar handles \u003ca href=\"https://tools.ietf.org/html/bcp47\"\u003eIETF BCP 47\u003c/a\u003e language tags via the JDK method \u003ca href=\"https://docs.oracle.com/javase/7/docs/api/java/util/Locale.html#forLanguageTag(java.lang.String)\"\u003eLocale.forLanguageTag\u003c/a\u003e.\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n```graphql\ntype Customer {\n  name: String\n  locale: Locale\n}\n\ntype Query {\n  customers(inLocale: Locale): [Customers]\n}\n```\n\nAn example query to look for customers in the Romanian locale might look like:\n\n```graphql\nquery {\n  customers(inLocale: \"ro-RO\") {\n    name\n    locale\n  }\n}\n```\n\n## Country Code Scalar\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003eScalar Definition\u003c/td\u003e\n\u003ctd\u003eDescription\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003e\nscalar CountryCode \n  @specifiedBy(url: \n    \"https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2\"\n  )\n\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eThe CountryCode scalar type as defined by \u003ca href=\"https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2\"\u003eISO 3166-1 alpha-2\u003c/a\u003e.\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nAn example declaration in SDL might be:\n\n```graphql\nscalar CountryCode\n\ntype Customer {\n  name: String\n  countryCode: CountryCode\n}\n```\n\nAnd example query might look like:\n\n```graphql\nquery {\n  customers(code: \"US\") {\n    name\n    countryCode\n  }\n}\n```\n\n## Currency Scalar\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003eScalar Definition\u003c/td\u003e\n\u003ctd\u003eDescription\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003e\nscalar Currency\n  @specifiedBy(url: \n    \"https://en.wikipedia.org/wiki/ISO_4217\"\n  )\n\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eA field whose value is an \u003ca href=\"https://en.wikipedia.org/wiki/ISO_4217\"\u003eISO-4217\u003c/a\u003e currency.\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nAn example declaration in SDL might be:\n\n```graphql\nscalar Currency\n\ntype Account {\n  id: String\n  currency: Currency\n  accountNumber: String\n}\n```\n\nAnd example query might look like:\n\n```graphql\nquery {\n  accounts(currency: \"USD\") {\n    id\n    currency\n    accountNumber\n  }\n}\n```\n\n## URL Scalars\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003eScalar Definition\u003c/td\u003e\n\u003ctd\u003eDescription\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003e\nscalar URL\n  @specifiedBy(url: \n    \"https://www.w3.org/Addressing/URL/url-spec.txt\"\n  )\n\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eAn url scalar that accepts string values like https://www.w3.org/Addressing/URL/url-spec.txt and produces \u003ccode\u003ejava.net.URL\u003c/code\u003e objects at runtime.\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n## Object / JSON Scalars\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003eScalar Definition\u003c/td\u003e\n\u003ctd\u003eDescription\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003escalar Object\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eAn object scalar that accepts any object as a scalar value.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre lang=\"graphql\"\u003escalar JSON\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003eA synonym for the \u003ccode\u003eObject\u003c/code\u003e scalar, it will accept any object as a scalar value.\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nOne of the design goals of GraphQL, is that the type system describes the shape of the data returned.\n\nThe `Object` / `JSON` scalars work against this some what because they can return compound values outside the type system. As such\nthey should be used sparingly. In general your should aim to describe the data via the GraphQL type system where you can and only\nresort to the `Object` / `JSON` scalars in very rare circumstances.\n\nAn example might be an extensible GraphQL system where systems can input custom metadata objects that cant be known at\nschema type design time.\n\nAn example declaration in SDL might be:\n\n```graphql\ntype Customer {\n  name: String\n  associatedMetaData: JSON\n}\n\ntype Query {\n  customers(filterSyntax: JSON): [Customers]\n}\n```\n\nAnd example query might look like:\n\n```graphql\nquery {\n  customers(\n    filterSyntax: {\n      startSpan: \"First\"\n      matchCriteria: { countryCode: \"AU\", isoCodes: [\"27B-34R\", \"95A-E23\"] }\n    }\n  ) {\n    name\n    associatedMetaData\n  }\n}\n```\n\nNote : The `JSON` scalar is a simple alias type to the `Object` scalar because often the returned data is a blob of JSON. They are\nall just objects at runtime in `graphql-java` terms and what network serialization protocol is up to you. Choose whichever name you think\nadds more semantic readers to your schema consumers.\n\n## Regex Scalars\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003eScalar Name\u003c/td\u003e\n\u003ctd\u003eDescription\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003eRegexScalar\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eAllows you to build a new scalar via a builder pattern using regular expressions.\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nThe RegexScalar has a builder where you provide one or more regex patterns that control the acceptable values\nfor a new scalar.\n\nYou name the scalar and it provides an implementation.\n\nFor example, imagine a `phoneNumber` scalar like this :\n\n```java\n\n    RegexScalar phoneNumberScalar = ExtendedScalars.newRegexScalar(\"phoneNumber\")\n            .addPattern(Pattern.compile(\"\\\\([0-9]*\\\\)[0-9]*\"))\n            .build()\n\n```\n","funding_links":[],"categories":["Implementations","Scalars"],"sub_categories":["Java","Code First"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-java%2Fgraphql-java-extended-scalars","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphql-java%2Fgraphql-java-extended-scalars","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-java%2Fgraphql-java-extended-scalars/lists"}