graphql / graphql/graphql-scalars
Regex based custom scalas + automatic discovery
- Dominant language
- TypeScript
- Stars
- 41
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
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?
Contributor guide
No contributing guide indexed for this repository
Research direction
No files, tests, or entry points are identified in the issue. First resolve the regex-based scalar and automatic-discovery design with maintainers; done means an agreed implementation location, endpoint contract, and tests for the proposed behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100