Standard Schema for GraphQL response.
Deprecated: This library will no longer be maintained. Use at your own risk!
npm install --save @dreamit/graphql-std-schema
TypeScript declarations are provided within the project.
The library exports one type and two functions.
Two options are available to configure validation behavior. See interface below.
export interface ValidationOptions { /** * In a GraphQL response only the fields "data", "errors" and "extensions" are allowed. When set to true * this checks allows additional fields. According to GraphQL spec October 2021 this should not be the case. */ allowAdditionalFieldsInResponse?: boolean /** * If value is a string, define if it should be parsed to an object. Otherwise an issue will be created. */ parseStringToObject?: boolean }
To validate an input the schema can be generated with graphQLResponseSchema() and the input can be validated with the
validate function. For a quick check the findIssues function can be used without a schema, the function will return a StandardSchemaV1.Issue[].
Example code:
// Optionally, provide options to adjust validation const schema = graphQLResponseSchema() const validationResults = schema['~standard'].validate(someInput) // Quick validation without a schema const foundValidationIssues = findIssues(someInput)
If you have problems, questions or issues please visit our Issue page and open a new issue if there are no fitting issues for your topic yet.
graphql-std-schema is under MIT-License.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4