Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
453e0b5
Combine invariants into AST-aware error.
sogko Jun 1, 2016
66e6c34
Remove unused fragment in queries in unit tests
sogko Jun 1, 2016
f1164a6
Deepen introspection query
sogko Jun 1, 2016
237fab4
Improve validation error message when field names conflict
sogko Jun 1, 2016
46c5850
Rename `type_comparator` test to mark as internal test.
sogko Jun 1, 2016
91a3aa2
Include possible field, argument, type names when validation fails (#…
sogko Jun 1, 2016
599c577
Minor clean up
sogko Jun 3, 2016
96fc0ad
Minor refactoring of error messages for unknown fields
sogko Jun 6, 2016
2b3b103
Unit test quotedOrList (suggestion quoting utility)
sogko Jun 6, 2016
b71c906
Bug: printer can print non-parsable value
sogko Jun 6, 2016
1670401
documentation of schema constructor
sogko Jun 6, 2016
73f83b4
isTypeSubTypeOf documentation
sogko Jun 6, 2016
8c1f318
Improved `KnownArgumentNames` tests for coverage
sogko Jun 7, 2016
a19ac6c
Export introspection in public API
sogko Jun 7, 2016
e324096
Update `NewSchema()` to use new exported introspective types
sogko Jun 7, 2016
9cbbd65
RFC: Schema Language Directives (#376)
sogko Jun 7, 2016
988ab2e
RFC: Directive location: schema definition (#382)
sogko Jun 7, 2016
47b81e3
Deprecated directive (#384)
sogko Jun 7, 2016
0dcbbd2
Revert back directives to use `var`; `const` not applicable here
sogko Jun 7, 2016
1225ab0
Deprecated directive (#384)
sogko Jun 7, 2016
c0a6554
Merge branch 'sogko/0.6.0' of https://github.com/sogko/graphql into s…
sogko Jun 7, 2016
d923568
Factor out closure functions to normal functions
sogko Jun 7, 2016
6b9ac5e
Factor out more closure functions
sogko Jun 7, 2016
bb27894
Validation: context.getFragmentSpreads now accepts selectionSet rathe…
sogko Jun 8, 2016
6fecefe
Validation: improving overlapping fields quality (#386)
sogko Jun 9, 2016
e13376c
Merge branch 'master' into sogko/0.6.0
sogko Jan 27, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ var _ Output = (*NonNull)(nil)
// Composite interface for types that may describe the parent context of a selection set.
type Composite interface {
Name() string
Description() string
String() string
Error() error
}

var _ Composite = (*Object)(nil)
Expand Down
47 changes: 45 additions & 2 deletions directives.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,39 @@
package graphql

const (
// Operations
DirectiveLocationQuery = "QUERY"
DirectiveLocationMutation = "MUTATION"
DirectiveLocationSubscription = "SUBSCRIPTION"
DirectiveLocationField = "FIELD"
DirectiveLocationFragmentDefinition = "FRAGMENT_DEFINITION"
DirectiveLocationFragmentSpread = "FRAGMENT_SPREAD"
DirectiveLocationInlineFragment = "INLINE_FRAGMENT"

// Schema Definitions
DirectiveLocationSchema = "SCHEMA"
DirectiveLocationScalar = "SCALAR"
DirectiveLocationObject = "OBJECT"
DirectiveLocationFieldDefinition = "FIELD_DEFINITION"
DirectiveLocationArgumentDefinition = "ARGUMENT_DEFINITION"
DirectiveLocationInterface = "INTERFACE"
DirectiveLocationUnion = "UNION"
DirectiveLocationEnum = "ENUM"
DirectiveLocationEnumValue = "ENUM_VALUE"
DirectiveLocationInputObject = "INPUT_OBJECT"
DirectiveLocationInputFieldDefinition = "INPUT_FIELD_DEFINITION"
)

// DefaultDeprecationReason Constant string used for default reason for a deprecation.
const DefaultDeprecationReason = "No longer supported"

// SpecifiedRules The full list of specified directives.
var SpecifiedDirectives = []*Directive{
IncludeDirective,
SkipDirective,
DeprecatedDirective,
}

// Directive structs are used by the GraphQL runtime as a way of modifying execution
// behavior. Type system creators will usually not create these directly.
type Directive struct {
Expand Down Expand Up @@ -76,7 +100,7 @@ func NewDirective(config DirectiveConfig) *Directive {
return dir
}

// IncludeDirective is used to conditionally include fields or fragments
// IncludeDirective is used to conditionally include fields or fragments.
var IncludeDirective = NewDirective(DirectiveConfig{
Name: "include",
Description: "Directs the executor to include this field or fragment only when " +
Expand All @@ -94,7 +118,7 @@ var IncludeDirective = NewDirective(DirectiveConfig{
},
})

// SkipDirective Used to conditionally skip (exclude) fields or fragments
// SkipDirective Used to conditionally skip (exclude) fields or fragments.
var SkipDirective = NewDirective(DirectiveConfig{
Name: "skip",
Description: "Directs the executor to skip this field or fragment when the `if` " +
Expand All @@ -111,3 +135,22 @@ var SkipDirective = NewDirective(DirectiveConfig{
DirectiveLocationInlineFragment,
},
})

// DeprecatedDirective Used to declare element of a GraphQL schema as deprecated.
var DeprecatedDirective = NewDirective(DirectiveConfig{
Name: "deprecated",
Description: "Marks an element of a GraphQL schema as no longer supported.",
Args: FieldConfigArgument{
"reason": &ArgumentConfig{
Type: String,
Description: "Explains why this element was deprecated, usually also including a " +
"suggestion for how to access supported similar data. Formatted" +
"in [Markdown](https://daringfireball.net/projects/markdown/).",
DefaultValue: DefaultDeprecationReason,
},
},
Locations: []string{
DirectiveLocationFieldDefinition,
DirectiveLocationEnumValue,
},
})
12 changes: 0 additions & 12 deletions directives_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,6 @@ func TestDirectivesWorksOnInlineFragmentIfFalseOmitsInlineFragment(t *testing.T)
b
}
}
fragment Frag on TestType {
b
}
`
expected := &graphql.Result{
Data: map[string]interface{}{
Expand All @@ -368,9 +365,6 @@ func TestDirectivesWorksOnInlineFragmentIfTrueIncludesInlineFragment(t *testing.
b
}
}
fragment Frag on TestType {
b
}
`
expected := &graphql.Result{
Data: map[string]interface{}{
Expand All @@ -395,9 +389,6 @@ func TestDirectivesWorksOnInlineFragmentUnlessFalseIncludesInlineFragment(t *tes
b
}
}
fragment Frag on TestType {
b
}
`
expected := &graphql.Result{
Data: map[string]interface{}{
Expand All @@ -422,9 +413,6 @@ func TestDirectivesWorksOnInlineFragmentUnlessTrueIncludesInlineFragment(t *test
b
}
}
fragment Frag on TestType {
b
}
`
expected := &graphql.Result{
Data: map[string]interface{}{
Expand Down
4 changes: 3 additions & 1 deletion executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,9 @@ func completeAbstractValue(eCtx *ExecutionContext, returnType Abstract, fieldAST
}

err := invariant(runtimeType != nil,
fmt.Sprintf(`Could not determine runtime type of value "%v" for field %v.%v.`, result, info.ParentType, info.FieldName),
fmt.Sprintf(`Abstract type %v must resolve to an Object type at runtime `+
`for field %v.%v with value "%v", received "%v".`,
returnType, info.ParentType, info.FieldName, result, runtimeType),
)
if err != nil {
panic(err)
Expand Down
Loading