At a glance
- Spec PR created on 2017-06-19 by IvanGoncharov
- Commit pushed: Add "Any" scalar type on 2017-06-19 by @IvanGoncharov
In some of our tool, we need to be able to pass an arbitrary value as an argument of a directive, i.e. value which can be anything and can’t be described as a single type. The only workaround we found is to define
scalar JSONwhich can accept any JSON value including objects and arrays.
Moreover, this as popular approach in the community:
- Graph.cool and Scaphold both allow user to use
JSONscalar in their schema
- graphql-type-json implements such scalar as a NPM package with 20+ packages depending on it.
- Apollo uses
scalar JSONas an example in their documentation.
AFAIK, this technique doesn’t contradict GraphQL spec and solves issues at hand. At the moment, it has very limited support from tooling since it’s not a built-in type and introspection provides you no clue beyond the name of a scalar.
The idea behind this PR is to formalize existing practice for creating
scalar JSONbut in protocol agnostic way, that’s why I propose to use
Anyas the name.
The last argument I have is that all type system that I know have some form of opt-out type:
anyin Flow and TypScript,
sql_variantin SQL and
Objectclass in C#/JAVA.