add option to export all operations

This commit is contained in:
Ben Kraft
2021-04-01 13:11:23 -07:00
parent de038dc428
commit fbf00f3bef
21 changed files with 124 additions and 52 deletions
+24 -3
View File
@@ -18,27 +18,48 @@ var defaultConfig = &Config{
}
type Config struct {
// The package name for the output code; defaults to the directory name of
// Generated
Package string `yaml:"package"`
// The filename with the GraphQL schema (in SDL format); defaults to
// schema.graphql
// TODO: Allow fetching a schema via introspection (will need to figure out
// how to convert that to SDL).
Schema string `yaml:"schema"`
// Filenames or globs with the queries; defaults to queries.graphql.
//
// These may be .graphql files, containing the queries in SDL format, or
// Go files, in which case any string-literal starting with (optional
// whitespace and) the string "# @genqlient" will be extracted as a query.
Queries []string `yaml:"queries"`
// If set, a file at this path will be generated containing the exact
// operations that genqlient will send to the server.
//
// This is useful for systems which require queries to be explicitly
// safelisted, especially for cases like queries involving fragments where
// it may not exactly match the input queries. The JSON is an object of
// the form
// {"operations": [{
// "operationName": "operationname",
// "query": "query operationName { ... }",
// }]}
// Keys may be added in the future.
//
// By default, no such file is written.
ExportOperations string `yaml:"export_operations"`
// The filename to which to write the generated code; defaults to
// generated.go
Generated string `yaml:"generated"`
// The package name for the output code; defaults to the directory name of
// Generated
Package string `yaml:"package"`
// Set to the fully-qualified name of a type which generated helpers should
// accept and use as the context.Context for HTTP requests. Defaults to
// context.Context; set to the empty string to omit context entirely.
ContextType string `yaml:"context_type"`
// If set, a snippet of Go code to get a *graphql.Client from the context
// (which will be named ctx). For example, this might do
// ctx.Value(myKey).(*graphql.Client). If omitted, client must be