All Projects → creditkarma → Graphql Validator

creditkarma / Graphql Validator

Licence: apache-2.0
A CLI tool to validate queries against a GraphQL Schema. The primary use case for this tool is to validate schema changes against an existing query store.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Graphql Validator

relay-compiler-plus
Custom relay compiler which supports persisted queries
Stars: ✭ 68 (-15%)
Mutual labels:  graphql-schema
Graphql
Pure PHP realization of GraphQL protocol
Stars: ✭ 717 (+796.25%)
Mutual labels:  graphql-schema
Sql To Graphql Schema Generator
⚛️ Generate GraphQL Scheme Online From SQL Query - https://sql-to-graphql.now.sh/
Stars: ✭ 32 (-60%)
Mutual labels:  graphql-schema
Graphql Auto Generating Cms
Use your existing graphQL schema to generate CMS in a couple steps. DEMO: http://cms-demo.web4fly.com/
Stars: ✭ 373 (+366.25%)
Mutual labels:  graphql-schema
Graphql Cost Analysis
A Graphql query cost analyzer.
Stars: ✭ 527 (+558.75%)
Mutual labels:  graphql-schema
Graphql Code Generator
A tool for generating code based on a GraphQL schema and GraphQL operations (query/mutation/subscription), with flexible support for custom plugins.
Stars: ✭ 7,993 (+9891.25%)
Mutual labels:  graphql-schema
straf
Convert Golang Struct To GraphQL Object On The Fly
Stars: ✭ 33 (-58.75%)
Mutual labels:  graphql-schema
Snowflaqe
A dotnet CLI tool to work with GraphQL queries: static query verification, type checking and code generating type-safe clients for F# and Fable.
Stars: ✭ 69 (-13.75%)
Mutual labels:  graphql-schema
Graphqldesigner.com
A developer web-app tool to rapidly prototype a full stack implementation of GraphQL with React.
Stars: ✭ 587 (+633.75%)
Mutual labels:  graphql-schema
Fullstack Graphql
🌈 Simple Fullstack GraphQL Application. API built with Express + GraphQL + Sequelize (supports MySQL, Postgres, Sqlite and MSSQL). WebApp built with React + Redux to access the API. Written in ES6 using Babel + Webpack.
Stars: ✭ 955 (+1093.75%)
Mutual labels:  graphql-schema
Typegql
Create GraphQL schema with TypeScript classes.
Stars: ✭ 415 (+418.75%)
Mutual labels:  graphql-schema
Get Graphql Schema
Fetch and print the GraphQL schema from a GraphQL HTTP endpoint. (Can be used for Relay Modern.)
Stars: ✭ 443 (+453.75%)
Mutual labels:  graphql-schema
Strawberry
A new GraphQL library for Python 🍓
Stars: ✭ 891 (+1013.75%)
Mutual labels:  graphql-schema
Vim Graphql
A Vim plugin that provides GraphQL file detection, syntax highlighting, and indentation.
Stars: ✭ 357 (+346.25%)
Mutual labels:  graphql-schema
Graphql Modules
⚠️ [DEPRECATED] GraphQL module library for Apollo.
Stars: ✭ 53 (-33.75%)
Mutual labels:  graphql-schema
fullstack-graphql-angular
Simple Fullstack GraphQL Application with Angular CLI + Redux. API built with Typescript + Express + GraphQL + Sequelize (supports MySQL, Postgres, Sqlite and MSSQL). WebApp built with Angular CLI + Redux + Async Middleware to access the API.
Stars: ✭ 67 (-16.25%)
Mutual labels:  graphql-schema
Type Graphql
Create GraphQL schema and resolvers with TypeScript, using classes and decorators!
Stars: ✭ 6,864 (+8480%)
Mutual labels:  graphql-schema
Graphql Schema Language Cheat Sheet
GraphQL Shorthand Notation Cheat Sheet
Stars: ✭ 1,181 (+1376.25%)
Mutual labels:  graphql-schema
Graphql Typescript
Define and build GraphQL Schemas using typed classes
Stars: ✭ 67 (-16.25%)
Mutual labels:  graphql-schema
Graphql Config
One configuration for all your GraphQL tools (supported by most tools, editors & IDEs)
Stars: ✭ 883 (+1003.75%)
Mutual labels:  graphql-schema

graphql-validator

A CLI tool to validate queries against a GraphQL Schema. The primary use case for this tool is to validate schema changes against an existing query store.

Installation

To use the validator as a command line tool

npm install -g graphql @creditkarma/graphql-validator

To use the validator locally in a project

npm install --save graphql @creditkarma/graphql-validator

Usage

Given the following files

schema/schema.graphql

schema {
  query: RootQuery
}

schema/rootQuery.graphql

type RootQuery {
  testString: String
}

queries/test.graphql

{testString}

Validate the query

Validate the query with the following code:

const loadSchema = require('@creditkarma/graphql-loader')
const validator = require('@creditkarma/graphql-validator')

loadSchema('./schema/*.graphql', (err, schema) => {
  validator.validateQueryFiles('./queries/*.graphql', schema, (errors) => {
    if (errors) {
         console.log('errors', errors);
    } else {
        console.log('All queries validated');
    }
  })
})

Validate the query using promises:

const loadSchema = require('@creditkarma/graphql-loader')
const validator = require('@creditkarma/graphql-validator')

loadSchema('./schema/*.graphql').then((schema) => {
  validator.validateQueryFiles('./queries/*.graphql', schema).then((results) => {
    console.log(results)
  })
})

Validate query using CLI tool

> graphql-validator -s "./schema/**/*.graphql" "./queries/*.graphql"

The validator will first load and validate the schema, throwing errors if the schema isn't valid. Then it will check each query in the file glob by parsing the query and validating it against the schema. If errors are found, the will be displayed by file name and exit with exit code 1.

Note: you must use quotes around each file glob or the utility will not work properly.

Development

Install dependencies with

npm install
npm run typings

Build

npm run build

Run test in watch mode

npm run test:watch

Contributing

For more information about contributing new features and bug fixes, see our Contribution Guidelines. External contributors must sign Contributor License Agreement (CLA)

License

This project is licensed under Apache License Version 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].