Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GraphQL scalar definition not supported

See original GitHub issue

cruddl 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:open
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

Yogucommented, Sep 16, 2019

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?

Yogucommented, Sep 17, 2019

Something like regex would be a start so we could at least support scalar definitions to some degree. However, the lack of callbacks is problematic for several reasons. Validation is one. But there are others such as audit logging that could become really problematic for integration of cruddl.

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 is profileConsumer 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 ProjectSources. For example, we could make the system scalars configurable. That would be pretty simple actually - it’s just an array of GraphQLScalarType classes. We could easily make this list configurable.

it can’t be an impenetrable line between graphql and arango. Developers need to be able to inject and extract data along that pipeline.

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 into executeExt. This method gets passed something called QueryTree 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found