package
0.31.8
Repository: https://github.com/fraym/freym-api.git
Documentation: pkg.go.dev

# README

graphql

This package provides helpers that simplify handling of graphql related things.

Schema parsing

Create a struct representaiton of your schema objects:

schema, err := graphql.NewSchema(schemaString)
if err != nil {
	panic(err)
}

The returned schema struct offers useful functions that can be used to inspect the schema.

Schema validation

You can use this library to validate a given graphql schema against your requirements:

Instantiationg the validators

There are validators for directives, fields and objeccts.

validator := graphql.NewSchemaValidator(&validator.ObjectConfig{
	// configure your object requirements here
}, &validator.DirectiveConfig{
	// configure your directive requirements here
}, &validator.FieldConfig{
	// configure your field requirements here
})

if err := validator.Validate(schema); err != nil {
	panic(err)
}

Schema printing

You can print your schema to a graphql schema string using:

schema, err := graphql.NewSchema(schemaString)
if err != nil {
	panic(err)
}

generatedSchemaString, err := schema.GetString()
if err != nil {
	panic(err)
}

The generatedSchemaString will be logically equal to the schama that you one provided as schemaString (It might have differences in formatting, therefore it will not be 100% equal).

Testing

For testing purposes the schema package provides mocks that can be used to mock the validators in your project:

ObjectValidator:

validator := validator.MockObjectValidator{}

FieldValidator:

validator := validator.MockFieldValidator{}

DirectiveValidator:

validator := validator.MockDirectiveValidator{}

License

This project is licensed under the MIT License. See the LICENSE file for details.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author
No description provided by the author

# Structs

No description provided by the author