GraphQL scalar definition not supported
See original GitHub issuecruddl appears to be throwing errors on Graphql documentation syntax. If my schema has something like this:
"""
IS08601 time duration
"""
scalar Duration
Processing through cruddl reports errors like this:
[error]: uncaughtException: Project has errors:
Error: This kind of definition is not allowed. Only object and enum type definitions are allowed. at schema.graphqls:2:1
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Custom scalars - Apollo GraphQL Docs
To define a custom scalar, add it to your schema like so: GraphQL ... How the JSON-compatible representation is deserialized to the back-end...
Read more >Schemas and Types - GraphQL
We'll go over scalar types more later. String! means that the field is non-nullable, meaning that the GraphQL service promises to always give...
Read more >GraphQL limitations - IBM
GraphQL limitations · Specialized handling of custom scalars is not supported, except for validation of the Long custom scalar type. · The ...
Read more >What Are Scalar Types in GraphQL? | StepZen blog
Here, String and Int are two of GraphQL's built-in scalar types. We'll talk about what that means and how you can add your...
Read more >Custom Scalars in GraphQL - ITNEXT
Defining a custom scalar type in the schema is not enough. We also need to tell the GraphQL engine how to convert values...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, custom scalars are not supported by cruddl. To implement it, we first need to decide how they can be configured by the schema author, because we can’t just use callbacks for validation (cruddl never uses callbacks for modelling). We could e.g. allow to specify a regular expression to validate scalars. What do you think?
I didn’t write cruddl does not use callbacks for configuration - it already does in several instances (just look at
ProjectConfig
, it’s full of optional callbacks). One callback isprofileConsumer
which gets called on each query - might go into the direction of audit logging.I meant that modelling should not require callbacks. Maybe the goals of cruddl and your requirements are not exactly overlapping here - we use cruddl in a generic component called “Model Manager” where users can dynamically define their schema via a web interface. They can’t just implement a cruddl callback.
However, I’m ok with callbacks and extensive configuration if it’s not directly coupled to the cruddl type definitions in the
ProjectSource
s. For example, we could make the system scalars configurable. That would be pretty simple actually - it’s just an array ofGraphQLScalarType
classes. We could easily make this list configurable.This line is the opposite of impemetrable! Actually, that’s the part of cruddl that’s closes to a “plugin” architecture. When creating a schema, you specify a database adapter. There, you can pass custom database adapters. For example, you can create a subclass of
ArangoDBAdapter
(or use composition) and hook yourself intoexecuteExt
. This method gets passed something calledQueryTree
which is an abstract representation of the query or mutation to be executed. You can e.g. modify the query tree or do audit checks, and then pass it to the original ArangoDB Adapter.However, the modelling features currently don’t follow a plugin architecture. In an earlier version of cruddl, we used a pipeline approach to gradually “enhance” the cruddl-input to the real, executable GraphQL schema. However, that approach got pretty messy pretty quickly, and we developed a framework that allows us to implement features in a cleaner way.