Skip to content

Commit 1f5572c

Browse files
Embed prelude (#214)
* use file embedding (Go 1.16) to embed prelude.graphql rather than using a long (and redundant) string literal * Remove inliner.go and its //go:generate use in schema.go. This is no longer necessary with use of //go:embed prelude.graphql
1 parent c0c2729 commit 1f5572c

File tree

3 files changed

+8
-36
lines changed

3 files changed

+8
-36
lines changed

validator/inliner/inliner.go

Lines changed: 0 additions & 32 deletions
This file was deleted.

validator/prelude.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
package validator
22

3-
import "github.com/vektah/gqlparser/v2/ast"
3+
import (
4+
_ "embed"
5+
"github.com/vektah/gqlparser/v2/ast"
6+
)
7+
8+
//go:embed prelude.graphql
9+
var preludeGraphql string
410

511
var Prelude = &ast.Source{
612
Name: "prelude.graphql",
7-
Input: "# This file defines all the implicitly declared types that are required by the graphql spec. It is implicitly included by calls to LoadSchema\n\n\"The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.\"\nscalar Int\n\n\"The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).\"\nscalar Float\n\n\"The `String`scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.\"\nscalar String\n\n\"The `Boolean` scalar type represents `true` or `false`.\"\nscalar Boolean\n\n\"\"\"The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as \"4\") or integer (such as 4) input value will be accepted as an ID.\"\"\"\nscalar ID\n\n\"The @include directive may be provided for fields, fragment spreads, and inline fragments, and allows for conditional inclusion during execution as described by the if argument.\"\ndirective @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT\n\n\"The @skip directive may be provided for fields, fragment spreads, and inline fragments, and allows for conditional exclusion during execution as described by the if argument.\"\ndirective @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT\n\n\"The @deprecated built-in directive is used within the type system definition language to indicate deprecated portions of a GraphQL service's schema, such as deprecated fields on a type, arguments on a field, input fields on an input type, or values of an enum type.\"\ndirective @deprecated(reason: String = \"No longer supported\") on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | ENUM_VALUE\n\n\"The @specifiedBy built-in directive is used within the type system definition language to provide a scalar specification URL for specifying the behavior of custom scalar types.\"\ndirective @specifiedBy(url: String!) on SCALAR\n\ntype __Schema {\n description: String\n types: [__Type!]!\n queryType: __Type!\n mutationType: __Type\n subscriptionType: __Type\n directives: [__Directive!]!\n}\n\ntype __Type {\n kind: __TypeKind!\n name: String\n description: String\n # must be non-null for OBJECT and INTERFACE, otherwise null.\n fields(includeDeprecated: Boolean = false): [__Field!]\n # must be non-null for OBJECT and INTERFACE, otherwise null.\n interfaces: [__Type!]\n # must be non-null for INTERFACE and UNION, otherwise null.\n possibleTypes: [__Type!]\n # must be non-null for ENUM, otherwise null.\n enumValues(includeDeprecated: Boolean = false): [__EnumValue!]\n # must be non-null for INPUT_OBJECT, otherwise null.\n inputFields: [__InputValue!]\n # must be non-null for NON_NULL and LIST, otherwise null.\n ofType: __Type\n # may be non-null for custom SCALAR, otherwise null.\n specifiedByURL: String\n}\n\ntype __Field {\n name: String!\n description: String\n args: [__InputValue!]!\n type: __Type!\n isDeprecated: Boolean!\n deprecationReason: String\n}\n\ntype __InputValue {\n name: String!\n description: String\n type: __Type!\n defaultValue: String\n}\n\ntype __EnumValue {\n name: String!\n description: String\n isDeprecated: Boolean!\n deprecationReason: String\n}\n\nenum __TypeKind {\n SCALAR\n OBJECT\n INTERFACE\n UNION\n ENUM\n INPUT_OBJECT\n LIST\n NON_NULL\n}\n\ntype __Directive {\n name: String!\n description: String\n locations: [__DirectiveLocation!]!\n args: [__InputValue!]!\n isRepeatable: Boolean!\n}\n\nenum __DirectiveLocation {\n QUERY\n MUTATION\n SUBSCRIPTION\n FIELD\n FRAGMENT_DEFINITION\n FRAGMENT_SPREAD\n INLINE_FRAGMENT\n VARIABLE_DEFINITION\n SCHEMA\n SCALAR\n OBJECT\n FIELD_DEFINITION\n ARGUMENT_DEFINITION\n INTERFACE\n UNION\n ENUM\n ENUM_VALUE\n INPUT_OBJECT\n INPUT_FIELD_DEFINITION\n}\n",
13+
Input: preludeGraphql,
814
BuiltIn: true,
915
}

validator/schema.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//go:generate go run ./inliner/inliner.go
2-
31
package validator
42

53
import (

0 commit comments

Comments
 (0)