Skip to main content

Add "Any" scalar type

At a glance​

Timeline​


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:

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.