graphql-constraint-directive | Validate GraphQL fields | GraphQL library
kandi X-RAY | graphql-constraint-directive Summary
kandi X-RAY | graphql-constraint-directive Summary
Validate GraphQL fields
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Generates a constraint type .
graphql-constraint-directive Key Features
graphql-constraint-directive Examples and Code Snippets
Community Discussions
Trending Discussions on graphql-constraint-directive
QUESTION
Im a beginner trying to set up a graphql API with apollo-express and prisma
All was going well, but than I decided to use this library to add input validation: graphql-constraint-directive
It requires me to use makeExecutableSchema to build my schema so I can use the schemaDirectives param
My code to start the server was like this:
...ANSWER
Answered 2019-Sep-02 at 15:05Whether you use makeExecutableSchema
or pass the typeDefs
and resolvers
to the ApolloServer
constructor directly shouldn't matter -- Apollo Server uses makeExecutableSchema
under the hood anyway. In fact, you can just pass the directive map to the constructor directly:
QUESTION
I am looking for a way to include extra info in the schema so the API consumer knows what is expected. Think along the lines of a max length on a string or something. I expect this to be in the schema since that basically replaces the API documentation, right?
I have found this: https://github.com/confuser/graphql-constraint-directive which appears to be similar to what I want, however I don't need the implementation/enforcement since django does that already. I just want to communicate these constraints on input fields.
I am very new to this all, so is there maybe a concept of graphql I am missing? Or how do I add this kind of information in the schema?
EDIT: Maybe this is not only for documenting, but also to tell the frontend how to render fields and/or be able to do some frontend validation. Basically like an OPTIONS request or something.
...ANSWER
Answered 2019-Apr-08 at 10:42If all you're looking to do is to document something about a specific field or type, you can set a description
on either one. Adding a description doesn't seem to be outlined in the official docs, but there is this issue about it.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install graphql-constraint-directive
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page