Closed
Description
ConstraintString leaked through introspection. Is it by design?
This makes GraphiQL unhappy.
Error: Invalid or incomplete schema, unknown type: ConstraintString. Ensure that a full introspection query is used in order to build a client schema.
ConstraintString can be revealed by the following query:
query Introspection {
__schema {
types {
name
inputFields {
type {
name
}
}
}
}
}
Metadata
Metadata
Assignees
Labels
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
confuser commentedon Jun 8, 2018
No, certainly not by design. Possibly a bug within
graphql-tools
.yvele commentedon Jun 13, 2018
I have the same problem, and I filled an issue within
graphql-tools
ardatan/graphql-tools#842Edit: I'm having this issue when trying to make schema stitching on underlying schema having directive constraints
koresar commentedon Jun 25, 2018
UPD: ignore the below. The directive stopped working. :)
UPD2: If you'd remove the two scalars below it will make the directive work, but will break client side retrospection. So, choose your destiny. :)
I found a workaround! Omg, took a while.
Add this to your
.graphql
schema file (if you have one though):koresar commentedon Jun 25, 2018
@confuser hey James,
Quick question. In this article
https://dev-blog.apollodata.com/reusable-graphql-schema-directives-131fb3a177d1
they suggest to override
field.resolver
. SeeAuthDirective
example.Any reason you went by creating the new
ConstraintString
type class?confuser commentedon Jun 25, 2018
@koresar The recommendation seemed to be using custom scalar types to achieve this, rather than overriding the resolver function https://www.apollographql.com/docs/graphql-tools/schema-directives.html#Enforcing-value-restrictions I'm certainly open to switching to a resolver function instead if it eases pains people are facing.
koresar commentedon Jun 25, 2018
Frankly, I tried this:
But for some reason the
resolve
is never hit. ThevisitInputFieldDefinition
is executed for every field though.So, not sure what to do frankly.
koresar commentedon Jun 25, 2018
I debugged a little. TL;DR: The
makeExecutableSchema
does not replace the directive object in schema.graphql-import
people tell you to "declare the@constraint
scalar in .graphql file". It effectively creates a directive object in schema. Which is right thing to do IMO. My IDE stops complaining about "undeclared directive!".makeExecutableSchema
accepts theschemaDirectives
and applies the schema visitor to them. But it does not replace the previously declared directive generated bygraphql-import
.Here is a screenshot. I made it in node.js debugger one step before exiting the

makeExecutableSchema
. Basically, thatschema
variable is what I get.@confuser where should I rant about it next? In apollographql/graphql-tools ? :)
koresar commentedon Jul 4, 2018
I solved the problem. The
@constaint
is fully working. What I did:graphql-yoga
and thegraphql-import
.Turns out Prisma and Apollo packages are not fully compatible.
Now I'm using Apollo Stack v2 (currently RC). The documentation does not match the actual API yet, but I figured all out.
confuser commentedon Jul 4, 2018
@koresar Interesting, so the new
apollo-server
v2 solves the issue with schema stitching without any changes here? I presume it doesn't resolve the problem you mentioned earlier around overwriting the resolver function instead of using custom scalars?koresar commentedon Jul 5, 2018
Sorry, should have mentioned. There were actually a lot of changes.
I had to rewrite schema stitching.
#import
statements, andmergeSchema()
JS function.It did solve all the problems I had.
The high level solution: do not use Prisma and Apollo packages in the same project. They are often incompatible.
koresar commentedon Jul 6, 2018
Ok. I was wrong. Again. No, I did not fix all the problems I have. Even Apollo Stack v2 didn't help.
Currently:
If I follow the README.md instructions then I get this error in the GraphQL Playground console:
Invalid or incomplete schema, unknown type: ConstraintString
.If I add
scalar ConstraintString
to my schema then the directive stops working.I believe that official Apollo docs are wrong: https://www.apollographql.com/docs/apollo-server/v2/features/creating-directives.html#Enforcing-value-restrictions
This way of implementing it does not work.
31 remaining items