Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL scalar definition not supported #96

Open
robross0606 opened this issue Sep 13, 2019 · 7 comments
Open

GraphQL scalar definition not supported #96

robross0606 opened this issue Sep 13, 2019 · 7 comments
Labels
enhancement New feature or request

Comments

@robross0606
Copy link

robross0606 commented Sep 13, 2019

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
@robross0606
Copy link
Author

FYI, I also tried with alternate syntax like this:

"IS08601 time duration"
scalar Duration

However, the same error occurs.

@robross0606
Copy link
Author

Actually, now I think it is just the use of scalar at all that is causing the issue.

@robross0606 robross0606 changed the title GraphQL documentation syntax not supported GraphQL scalar definition not supported Sep 13, 2019
@Yogu
Copy link
Member

Yogu commented 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?

@Yogu Yogu added the enhancement New feature or request label Sep 16, 2019
@robross0606
Copy link
Author

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 know you don't support it, so my thought was to integrate some of those things (i.e. audit logging) as other custom directives so I could chain things together. cruddl is a great idea, but it can't be an impenetrable line between graphql and arango. Developers need to be able to inject and extract data along that pipeline.

@robross0606
Copy link
Author

Hmmm... Now I'm not even sure cruddl will allow the addition of other directive handlers.

@robross0606
Copy link
Author

robross0606 commented Sep 16, 2019

Okay, so this is a non-starter as well. Cruddl throws up if you also reference other non-cruddl directives. By graphql standard, @Directives are supposed to be cumulative and chainable from left-to-right. There is no reason cruddl should be throwing an error if it sees a directive it doesn't understand. Is there a way to pass other directive handlers into cruddl so it knows about the use of other non-cruddl directives such as graphql-constraint-directive? I've split this off into #98.

@Yogu
Copy link
Member

Yogu commented 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants