Skip to content

graphql-js v0.6.0 #192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Mar 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7074425
Combine invariants into AST-aware error.
sogko Jun 1, 2016
019bce8
Remove unused fragment in queries in unit tests
sogko Jun 1, 2016
c3d5b0d
Deepen introspection query
sogko Jun 1, 2016
d54ea4d
Improve validation error message when field names conflict
sogko Jun 1, 2016
002c85d
Rename `type_comparator` test to mark as internal test.
sogko Jun 1, 2016
7be4d3e
Include possible field, argument, type names when validation fails (#…
sogko Jun 1, 2016
71a0ed1
Minor clean up
sogko Jun 3, 2016
73bd2ff
Minor refactoring of error messages for unknown fields
sogko Jun 6, 2016
e0d0cb8
Unit test quotedOrList (suggestion quoting utility)
sogko Jun 6, 2016
a664da1
Bug: printer can print non-parsable value
sogko Jun 6, 2016
b0d8f12
documentation of schema constructor
sogko Jun 6, 2016
4b534a6
isTypeSubTypeOf documentation
sogko Jun 6, 2016
da2a648
Improved `KnownArgumentNames` tests for coverage
sogko Jun 7, 2016
b9cdfec
Export introspection in public API
sogko Jun 7, 2016
624ff8e
Update `NewSchema()` to use new exported introspective types
sogko Jun 7, 2016
e7fdfd1
RFC: Schema Language Directives (#376)
sogko Jun 7, 2016
3a56b94
RFC: Directive location: schema definition (#382)
sogko Jun 7, 2016
e3f255f
Deprecated directive (#384)
sogko Jun 7, 2016
357bcc5
Revert back directives to use `var`; `const` not applicable here
sogko Jun 7, 2016
1926b6c
Factor out closure functions to normal functions
sogko Jun 7, 2016
1a94451
Factor out more closure functions
sogko Jun 7, 2016
c96ac89
Validation: context.getFragmentSpreads now accepts selectionSet rathe…
sogko Jun 8, 2016
12580b5
Validation: improving overlapping fields quality (#386)
sogko Jun 9, 2016
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 @@ -696,7 +696,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