Validation Middleware

The Validation Middleware is a Implementation of all rules specified in the graphql specification to validate Requests: https://facebook.github.io/graphql/draft/#sec-Validation

Configure the proxy:

prox := http.NewFastStaticProxy(http.FastStaticProxyConfig{
MiddleWares: []middleware.GraphqlMiddleware{
&middleware.ValidationMiddleware{},
},
RequestConfigProvider: proxy.NewStaticSchemaProvider(proxy.RequestConfig{
Schema: &schema,
BackendAddr: []byte(staticProxyBackendURL),
BackendHost: staticProxyBackendAddr,
AddHeadersToContext: addHeadersToContext,
}),
})

Example Schema:

scalar String
schema {
query: Query
}
type Query {
documents: [Document]
}
type Document implements Node {
owner: String
sensitiveInformation: String
}

Valid Query:

query myDocuments {documents {sensitiveInformation}}

Invalid Query:

query myDocuments {documents {fieldNotExists}}