graphql / graphql-scalars Goto Github PK
View Code? Open in Web Editor NEWGraphQL Scalars specifications repo.
GraphQL Scalars specifications repo.
To discuss: how do we want to bless certain custom scalars for inclusion in graphql-js? Is it just an ad-hoc vote of the working group? Or should we not bless any such scalars, and leave the community to figure it out? There's definitely a case to be made for standard reference implementations of some key ones like DateTime...
I'm super excited about this initiative. Have you thought about allowing businesses to contribute their scalars here? Potentially in a structure like scalars/business_name/author_name
.
Right now we have:
2011-08-30T13:22:53.108+03:30
1983-10-20
But we're missing a way to represent a local date with a time like 2007-12-03T10:15:30
It cannot be represented as a DateTime
because the semantics are different. A LocalDateTime point in time might change if some of our governments decide to change timezones.
The specification could be relatively close to the Java LocalDateTime. I can write something up if there's interest.
Prior art:
This being part of the GraphQL foundation I expect that everybody needs to sign the CLA of the foundation before the code can be merged. @leebyron that correct?
Also: which license should be used for the specs?
The GraphQL spec itself states:
This specification was licensed under OWFa 1.0 in 2017. Copyright and trademark was transferred to the GraphQL Foundation in 2019.
I would expect we do the same for custom Scalars specs.
Here's my pitch for how the built URLs could work:
Urls follow a /namespace/scalar/version
hierarchy:
https://scalars.graphql.org/
https://scalars.graphql.org/namespace/
https://scalars.graphql.org/namespace/scalar
https://scalars.graphql.org/namespace/scalar/vA.B.C
https://scalars.graphql.org/namespace/scalar/vA
https://scalars.graphql.org/namespace/scalar/vA.B
Examples:
https://scalars.graphql.org/andimarek/datetime/v1.0.0
https://scalars.graphql.org/graphql/url/v2
Semver rules:
Implementation:
vA.B
to avoid merge conflicts for every PR.
vA.B.C
from any previous built page if the frontmatter version does not change in a merged PR.Example:
---
Name: DateTime
Version: v1.2
Authors: andimarek
---
# DateTime
...
Ticket for any discussion of what requirements we want to enforce before we accept a scalar definition to the repo. Off the top of my head:
Anything else?
Something that occurred to me, to discuss: who should we accept edits from (or e.g. new versions of an existing scalar), besides the original author? Other members of a shared org seem obvious, but there's no obvious path for sharing ownership over a single author's scalar.
Not sure if this actually matters, or if we should be encouraging more of a fork-and-evolve model?
Idea: we could add another custom scalar spec which is a subclass of the string template, which is regex based.
This means the input and output would be fully described with a regex (or two different regex for different input and output).
The main goal of this would be to offer some kind of automatic discovery of the regex. For example via dedicated URL. This would allow tools like GraphiQL to dynamically discover custom scalar specs and validate them and offer code completion.
Example:
spec for LocalDate
. The format is "yyyy-mm-dd"
regex for input and output is: "\d{4}-\d{2}-\d{2}".
The patterns for input and output could be reachable via:
scalars.graphql.org/andimarek/local-date/input-regex
scalars.graphql.org/andimarek/local-date/output-regex
Both endpoint would just return HTTP text with "\d{4}-\d{2}-\d{2}". Nothing else.
One implementation detail I am not sure is how we automatically could get the patterns from the template or maybe we just expect contributors to specify them in extra files?
@dondonz @leebyron what do you think? Would love to hear some ideas how to implement this. Maybe spec-md could help here even?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.