Skip to content

Commit 4423f25

Browse files
authored
Rename EntryPoints to RootOperationTypes (#542)
Rename entryPoints to RootOperationTypes to align with specification terminology. see: https://spec.graphql.org/June2018/#sec-Root-Operation-Types
1 parent 3951ad4 commit 4423f25

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

graphql.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func (s *Schema) exec(ctx context.Context, queryString string, operationName str
232232
return &Response{Errors: []*errors.QueryError{{Message: "graphql-ws protocol header is missing"}}}
233233
}
234234
if op.Type == query.Mutation {
235-
if _, ok := s.schema.EntryPoints["mutation"]; !ok {
235+
if _, ok := s.schema.RootOperationTypes["mutation"]; !ok {
236236
return &Response{Errors: []*errors.QueryError{{Message: "no mutations are offered by the schema"}}}
237237
}
238238
}
@@ -305,7 +305,7 @@ func (t *validationBridgingTracer) TraceValidation(context.Context) func([]*erro
305305
}
306306

307307
func validateRootOp(s *types.Schema, name string, mandatory bool) error {
308-
t, ok := s.EntryPoints[name]
308+
t, ok := s.RootOperationTypes[name]
309309
if !ok {
310310
if mandatory {
311311
return fmt.Errorf("root operation %q must be defined", name)

internal/exec/resolvable/resolvable.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,19 @@ func ApplyResolver(s *types.Schema, resolver interface{}) (*Schema, error) {
7070

7171
var query, mutation, subscription Resolvable
7272

73-
if t, ok := s.EntryPoints["query"]; ok {
73+
if t, ok := s.RootOperationTypes["query"]; ok {
7474
if err := b.assignExec(&query, t, reflect.TypeOf(resolver)); err != nil {
7575
return nil, err
7676
}
7777
}
7878

79-
if t, ok := s.EntryPoints["mutation"]; ok {
79+
if t, ok := s.RootOperationTypes["mutation"]; ok {
8080
if err := b.assignExec(&mutation, t, reflect.TypeOf(resolver)); err != nil {
8181
return nil, err
8282
}
8383
}
8484

85-
if t, ok := s.EntryPoints["subscription"]; ok {
85+
if t, ok := s.RootOperationTypes["subscription"]; ok {
8686
if err := b.assignExec(&subscription, t, reflect.TypeOf(resolver)); err != nil {
8787
return nil, err
8888
}
@@ -377,7 +377,7 @@ func (b *execBuilder) makeFieldExec(typeName string, f *types.FieldDefinition, m
377377
var out reflect.Type
378378
if methodIndex != -1 {
379379
out = m.Type.Out(0)
380-
sub, ok := b.schema.EntryPoints["subscription"]
380+
sub, ok := b.schema.RootOperationTypes["subscription"]
381381
if ok && typeName == sub.TypeName() && out.Kind() == reflect.Chan {
382382
out = m.Type.Out(0).Elem()
383383
}

internal/schema/schema.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ func Parse(s *types.Schema, schemaString string, useStringDescriptions bool) err
6767
s.EntryPointNames["subscription"] = "Subscription"
6868
}
6969
}
70-
s.EntryPoints = make(map[string]types.NamedType)
70+
s.RootOperationTypes = make(map[string]types.NamedType)
7171
for key, name := range s.EntryPointNames {
7272
t, ok := s.Types[name]
7373
if !ok {
7474
return errors.Errorf("type %q not found", name)
7575
}
76-
s.EntryPoints[key] = t
76+
s.RootOperationTypes[key] = t
7777
}
7878

7979
// Interface types need validation: https://spec.graphql.org/draft/#sec-Interfaces.Interfaces-Implementing-Interfaces

internal/validation/validation.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ func Validate(s *types.Schema, doc *types.ExecutableDefinition, variables map[st
117117
var entryPoint types.NamedType
118118
switch op.Type {
119119
case query.Query:
120-
entryPoint = s.EntryPoints["query"]
120+
entryPoint = s.RootOperationTypes["query"]
121121
case query.Mutation:
122-
entryPoint = s.EntryPoints["mutation"]
122+
entryPoint = s.RootOperationTypes["mutation"]
123123
case query.Subscription:
124-
entryPoint = s.EntryPoints["subscription"]
124+
entryPoint = s.RootOperationTypes["subscription"]
125125
default:
126126
panic("unreachable")
127127
}

introspection/introspection.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,23 @@ func (r *Schema) Directives() []*Directive {
4444
}
4545

4646
func (r *Schema) QueryType() *Type {
47-
t, ok := r.schema.EntryPoints["query"]
47+
t, ok := r.schema.RootOperationTypes["query"]
4848
if !ok {
4949
return nil
5050
}
5151
return &Type{t}
5252
}
5353

5454
func (r *Schema) MutationType() *Type {
55-
t, ok := r.schema.EntryPoints["mutation"]
55+
t, ok := r.schema.RootOperationTypes["mutation"]
5656
if !ok {
5757
return nil
5858
}
5959
return &Type{t}
6060
}
6161

6262
func (r *Schema) SubscriptionType() *Type {
63-
t, ok := r.schema.EntryPoints["subscription"]
63+
t, ok := r.schema.RootOperationTypes["subscription"]
6464
if !ok {
6565
return nil
6666
}

subscriptions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (s *Schema) Subscribe(ctx context.Context, queryString string, operationNam
2323
if !s.res.Resolver.IsValid() {
2424
return nil, errors.New("schema created without resolver, can not subscribe")
2525
}
26-
if _, ok := s.schema.EntryPoints["subscription"]; !ok {
26+
if _, ok := s.schema.RootOperationTypes["subscription"]; !ok {
2727
return nil, errors.New("no subscriptions are offered by the schema")
2828
}
2929
return s.subscribe(ctx, queryString, operationName, variables, s.res), nil

types/schema.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ package types
88
//
99
// http://spec.graphql.org/draft/#sec-Schema
1010
type Schema struct {
11-
// EntryPoints determines the place in the type system where `query`, `mutation`, and
11+
// RootOperationTypes determines the place in the type system where `query`, `mutation`, and
1212
// `subscription` operations begin.
1313
//
1414
// http://spec.graphql.org/draft/#sec-Root-Operation-Types
1515
//
16-
EntryPoints map[string]NamedType
16+
RootOperationTypes map[string]NamedType
1717

1818
// Types are the fundamental unit of any GraphQL schema.
1919
// There are six kinds of named types, and two wrapping types.

0 commit comments

Comments
 (0)