GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - tailrocks/graphql-java-datetime: GraphQL ISO Date is a set of RFC 3339 compliant date/time scalar types to be used with graphql-java.

BranchesTags
Open more actions menu

Latest commit

 

History

836 Commits
836 Commits

Folders and files

NameName
Last commit message
Last commit date
.github-gen
.github-gen
 
 
.github
.github
 
 
.run
.run
 
 
buildSrc
buildSrc
 
 
config/fleet
config/fleet
 
 
gradle
gradle
 
 
graphql-datetime-dgs-autoconfigure
graphql-datetime-dgs-autoconfigure
 
 
graphql-datetime-dgs-starter
graphql-datetime-dgs-starter
 
 
graphql-datetime-kickstart-spring-boot-starter
graphql-datetime-kickstart-spring-boot-starter
 
 
graphql-datetime-spring-boot-autoconfigure
graphql-datetime-spring-boot-autoconfigure
 
 
graphql-datetime-spring-boot-common
graphql-datetime-spring-boot-common
 
 
graphql-datetime-spring-boot-starter
graphql-datetime-spring-boot-starter
 
 
graphql-java-datetime
graphql-java-datetime
 
 
samples
samples
 
 
.gitignore
.gitignore
 
 
.tool-versions
.tool-versions
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle.kts
build.gradle.kts
 
 
build.sh
build.sh
 
 
check-dependency-updates.sh
check-dependency-updates.sh
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
publish-sonatype-release.sh
publish-sonatype-release.sh
 
 
publish-sonatype-snapshot.sh
publish-sonatype-snapshot.sh
 
 
renovate.json
renovate.json
 
 
settings.gradle.kts
settings.gradle.kts
 
 
test.sh
test.sh
 
 
version.sh
version.sh
 
 

Repository files navigation

graphql-java-datetime

License Latest Release PRs Welcome

GraphQL ISO Date is a set of RFC 3339 compliant date/time scalar types to be used with graphql-java.

Summary

A set of ISO 33601, RFC 3339 compatible date time scalars for GraphQL Java implementation (graphql-java), as well as starters for

  • GraphQL Java Kickstart graphql-java-kickstart
  • Netflix DGS Framework dgs-framework
  • Spring GraphQL spring-graphql

Serialization

java.util.Date, java.time.LocalDate, java.time.LocalDateTime

Format JSON String
yyyy-MM-dd'T'HH:MM:ss.SSS'Z' 2017-07-09T13:14:45.947Z
yyyy-MM-dd'T'HH:MM:ss'Z' 2017-07-09T11:54:42Z
yyyy-MM-dd'T'HH:MM:ss 2017-07-09T11:54:42
yyyy-MM-dd 2017-07-09

java.time.LocalTime

Format JSON String
HH:MM:ss.SSS 17:59:59.129
HH:MM:ss 17:59:59
HH:MM 17:59

java.time.Duration

JSON String
PT1H30M
P1DT3H30M
P3Y6M4DT12H30M5S

Usage

Spring Boot

This library supports the following popular graphql-java framework:

  • GraphQL Java Kickstart graphql-java-kickstart
  • Netflix DGS Framework dgs-framework
  • Spring GraphQL spring-graphql

Add one of the following starters according to your project.

Installation

Maven

Add the following to your pom.xml:

for GraphQL Java Kickstart:

<dependency>
    <groupId>com.tailrocks.graphql</groupId>
    <artifactId>graphql-datetime-kickstart-spring-boot-starter</artifactId>
    <version>6.0.0</version>
</dependency>

for Netflix DGS:

<dependency>
    <groupId>com.tailrocks.graphql</groupId>
    <artifactId>graphql-datetime-dgs-starter</artifactId>
    <version>6.0.0</version>
</dependency>

for Spring GraphQL:

<dependency>
    <groupId>com.tailrocks.graphql</groupId>
    <artifactId>graphql-datetime-spring-boot-starter</artifactId>
    <version>6.0.0</version>
</dependency>

Gradle

Add the following to your build.gradle:

for GraphQL Java Kickstart (Spring Boot):

implementation("com.tailrocks.graphql:graphql-datetime-kickstart-spring-boot-starter:6.0.0")

for DGS:

implementation("com.tailrocks.graphql:graphql-datetime-dgs-starter:6.0.0")

for Spring GraphQL:

implementation("com.tailrocks.graphql:graphql-datetime-spring-boot-starter:6.0.0")

Scalars

Add these scalars to your .graphqls schema file:

# java.util.Date implementation
scalar Date

# java.time.LocalDate implementation
scalar LocalDate

# java.time.LocalDateTime implementation
scalar LocalDateTime

# java.time.LocalTime implementation
scalar LocalTime

# java.time.OffsetDateTime implementation
scalar OffsetDateTime

# java.time.YearMonth implementation
scalar YearMonth

# java.time.Duration implementation
scalar Duration

You can rename the scalar however you want by simply adding the following properties to your application.yaml:

graphql:
  datetime:
    scalars:
      date:
        scalar-name: MyDate
      local-date:
        scalar-name: MyLocalDate
      local-date-time:
        scalar-name: MyLocalDateTime
      local-time:
        scalar-name: MyLocalTime
      offset-date-time:
        scalar-name: MyOffsetDateTime
      year-month:
        scalar-name: MyYearMonth
      duration:
        scalar-name: MyDuration

A custom format can be set for LocalDate and LocalDateTime only using the following properties in application.yaml

graphql:
  datetime:
    scalars:
      local-date:
        format: MM/dd/yyyy
      local-date-time:
        format: yyyy-MM-dd'T'HH:mm:ss

You can enable automatic zone conversion by adding the following property to your application.yaml. This will automatically convert between UTC and the default TimeZone for LocalDateTime:

graphql:
  datetime:
    scalars:
      zone-conversion-enabled: true

If using OffsetDateTime in order to present the offset and disable the automatic convertion to UTC from Jackson you should set to your application.yml the following:

spring:
  jackson:
    deserialization:
      adjust-dates-to-context-time-zone: false

Sample

Now you can use these scalars in your application. Here are graphql-datetime spring boot sample applications:

  • webmvc:
    • dgs: sample-graphql-datetime-dgs-webmvc
    • kickstart: sample-graphql-datetime-kickstart-webmvc
    • spring-graphql: sample-graphql-datetime-spring-boot-webmvc
  • webflux:
    • kickstart: sample-graphql-datetime-kickstart-webflux

Bugs

To report any bug, please use the project Issues section on GitHub.

Contributing

Please contribute using Github Flow. Create a branch, add commits, and open a pull request.

License

Copyright © 2017-2023 Alexey Zhokhov. All rights reserved.

This project is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.

About

GraphQL ISO Date is a set of RFC 3339 compliant date/time scalar types to be used with graphql-java.

Topics

datedatetimegraphqlgraphql-javascalarstime

Resources

Readme
Apache-2.0 license
Activity
Custom properties

Stars

153 stars

Watchers

4 watching

Forks

25 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.