At a glance
- Identifier: #325
- Stage: RFC 0 / Strawman
- Champion: @IvanGoncharov
- Latest activity: Spec PR created on 2017-06-19
- Spec PR: https://github.com/graphql/graphql-spec/pull/325
Spec PR description
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 JSON which 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 JSON but in protocol agnostic way, that’s why I propose to use Any as the name.
The last argument I have is that all type system that I know have some form of opt-out type: any in Flow and TypScript, void* in C/C++, sql_variant in SQL and Object class in C#/JAVA.
Timeline
- Spec PR created on 2017-06-19 by IvanGoncharov
- Commit pushed on 2017-06-19 by IvanGoncharov: Add "Any" scalar type