Skip to content

Commit d69a0b9

Browse files
author
abhif22
committed
Updated graph-gophers to tokopedia in import paths
1 parent 7a5f606 commit d69a0b9

11 files changed

Lines changed: 42 additions & 80 deletions

File tree

example/caching/caching.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"time"
66

7-
"github.com/graph-gophers/graphql-go/example/caching/cache"
7+
"github.com/tokopedia/graphql-go/example/caching/cache"
88
)
99

1010
const Schema = `

example/caching/server/server.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import (
66
"log"
77
"net/http"
88

9-
"github.com/graph-gophers/graphql-go"
10-
"github.com/graph-gophers/graphql-go/example/caching"
11-
"github.com/graph-gophers/graphql-go/example/caching/cache"
9+
"github.com/tokopedia/graphql-go"
10+
"github.com/tokopedia/graphql-go/example/caching"
11+
"github.com/tokopedia/graphql-go/example/caching/cache"
1212
)
1313

1414
var schema *graphql.Schema

example/social/server/server.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"log"
55
"net/http"
66

7-
"github.com/graph-gophers/graphql-go"
8-
"github.com/graph-gophers/graphql-go/example/social"
9-
"github.com/graph-gophers/graphql-go/relay"
7+
"github.com/tokopedia/graphql-go"
8+
"github.com/tokopedia/graphql-go/example/social"
9+
"github.com/tokopedia/graphql-go/relay"
1010
)
1111

1212
func main() {

example/social/social.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"strings"
88
"time"
99

10-
"github.com/graph-gophers/graphql-go"
10+
"github.com/tokopedia/graphql-go"
1111
)
1212

1313
const Schema = `

gqltesting/subscriptions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"strconv"
88
"testing"
99

10-
graphql "github.com/graph-gophers/graphql-go"
11-
"github.com/graph-gophers/graphql-go/errors"
10+
graphql "github.com/tokopedia/graphql-go"
11+
"github.com/tokopedia/graphql-go/errors"
1212
)
1313

1414
// TestResponse models the expected response

graphql_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import (
77
"testing"
88
"time"
99

10-
"github.com/graph-gophers/graphql-go"
11-
gqlerrors "github.com/graph-gophers/graphql-go/errors"
12-
"github.com/graph-gophers/graphql-go/example/starwars"
13-
"github.com/graph-gophers/graphql-go/gqltesting"
10+
"github.com/tokopedia/graphql-go"
11+
gqlerrors "github.com/tokopedia/graphql-go/errors"
12+
"github.com/tokopedia/graphql-go/example/starwars"
13+
"github.com/tokopedia/graphql-go/gqltesting"
1414
)
1515

1616
type helloWorldResolver1 struct{}

internal/exec/exec.go

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (r *Request) execSelections(ctx context.Context, sels []selected.Selection,
9797
} else {
9898
for _, f := range fields {
9999
f.out = new(bytes.Buffer)
100-
execFieldSelection(ctx, r, s, f, &pathSegment{path, f.field.Alias}, true)
100+
execFieldSelection(ctx, r, f, &pathSegment{path, f.field.Alias}, true, fixedRes, fromFixedResp)
101101
}
102102
}
103103

@@ -143,7 +143,7 @@ func collectFieldsToResolve(sels []selected.Selection, resolver reflect.Value, f
143143

144144
case *selected.TypenameField:
145145
sf := &selected.SchemaField{
146-
Field: s.Meta.FieldTypename,
146+
// Field: resolvable.Meta,
147147
Alias: sel.Alias,
148148
FixedResult: reflect.ValueOf(typeOf(sel, resolver)),
149149
}
@@ -453,47 +453,6 @@ func (r *Request) execSelectionSet(ctx context.Context, sels []selected.Selectio
453453
}
454454
}
455455

456-
func (r *Request) execList(ctx context.Context, sels []selected.Selection, typ *common.List, path *pathSegment, s *resolvable.Schema, resolver reflect.Value, out *bytes.Buffer) {
457-
l := resolver.Len()
458-
entryouts := make([]bytes.Buffer, l)
459-
460-
if selected.HasAsyncSel(sels) {
461-
var wg sync.WaitGroup
462-
wg.Add(l)
463-
for i := 0; i < l; i++ {
464-
go func(i int) {
465-
defer wg.Done()
466-
defer r.handlePanic(ctx)
467-
r.execSelectionSet(ctx, sels, typ.OfType, &pathSegment{path, i}, s, resolver.Index(i), &entryouts[i])
468-
}(i)
469-
}
470-
wg.Wait()
471-
} else {
472-
for i := 0; i < l; i++ {
473-
r.execSelectionSet(ctx, sels, typ.OfType, &pathSegment{path, i}, s, resolver.Index(i), &entryouts[i])
474-
}
475-
}
476-
477-
_, listOfNonNull := typ.OfType.(*common.NonNull)
478-
479-
out.WriteByte('[')
480-
for i, entryout := range entryouts {
481-
// If the list wraps a non-null type and one of the list elements
482-
// resolves to null, then the entire list resolves to null.
483-
if listOfNonNull && resolvedToNull(&entryout) {
484-
out.Reset()
485-
out.WriteString("null")
486-
return
487-
}
488-
489-
if i > 0 {
490-
out.WriteByte(',')
491-
}
492-
out.Write(entryout.Bytes())
493-
}
494-
out.WriteByte(']')
495-
}
496-
497456
func unwrapNonNull(t common.Type) (common.Type, bool) {
498457
if nn, ok := t.(*common.NonNull); ok {
499458
return nn.OfType, true

internal/exec/subscribe.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import (
88
"reflect"
99
"time"
1010

11-
"github.com/graph-gophers/graphql-go/errors"
12-
"github.com/graph-gophers/graphql-go/internal/common"
13-
"github.com/graph-gophers/graphql-go/internal/exec/resolvable"
14-
"github.com/graph-gophers/graphql-go/internal/exec/selected"
15-
"github.com/graph-gophers/graphql-go/internal/query"
11+
"github.com/tokopedia/graphql-go/errors"
12+
"github.com/tokopedia/graphql-go/internal/common"
13+
"github.com/tokopedia/graphql-go/internal/exec/resolvable"
14+
"github.com/tokopedia/graphql-go/internal/exec/selected"
15+
"github.com/tokopedia/graphql-go/internal/query"
1616
)
1717

1818
type Response struct {
@@ -24,13 +24,13 @@ func (r *Request) Subscribe(ctx context.Context, s *resolvable.Schema, op *query
2424
var result reflect.Value
2525
var f *fieldToExec
2626
var err *errors.QueryError
27+
var fromFixedResponse bool
2728
func() {
2829
defer r.handlePanic(ctx)
2930

3031
sels := selected.ApplyOperation(&r.Request, s, op)
3132
var fields []*fieldToExec
32-
collectFieldsToResolve(sels, s, s.Resolver, &fields, make(map[string]*fieldToExec))
33-
33+
collectFieldsToResolve(sels, s.Resolver, &fields, make(map[string]*fieldToExec), &fromFixedResponse)
3434
// TODO: move this check into validation.Validate
3535
if len(fields) != 1 {
3636
err = errors.Errorf("%s", "can subscribe to at most one subscription at a time")
@@ -118,9 +118,12 @@ func (r *Request) Subscribe(ctx context.Context, s *resolvable.Schema, op *query
118118
// resolve response
119119
func() {
120120
defer subR.handlePanic(subCtx)
121-
121+
var (
122+
fixedRes interface{}
123+
fromFixedResp bool
124+
)
122125
var buf bytes.Buffer
123-
subR.execSelectionSet(subCtx, f.sels, f.field.Type, &pathSegment{nil, f.field.Alias}, s, resp, &buf)
126+
subR.execSelectionSet(subCtx, f.sels, f.field.Type, &pathSegment{nil, f.field.Alias}, resp, &buf, fixedRes, &fromFixedResp)
124127

125128
propagateChildError := false
126129
if _, nonNullChild := f.field.Type.(*common.NonNull); nonNullChild && resolvedToNull(&buf) {

introspection_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import (
66
"io/ioutil"
77
"testing"
88

9-
"github.com/graph-gophers/graphql-go"
10-
"github.com/graph-gophers/graphql-go/example/social"
11-
"github.com/graph-gophers/graphql-go/example/starwars"
9+
"github.com/tokopedia/graphql-go"
10+
"github.com/tokopedia/graphql-go/example/social"
11+
"github.com/tokopedia/graphql-go/example/starwars"
1212
)
1313

1414
func TestSchema_ToJSON(t *testing.T) {

subscription_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import (
66
"errors"
77
"testing"
88

9-
graphql "github.com/graph-gophers/graphql-go"
10-
qerrors "github.com/graph-gophers/graphql-go/errors"
11-
"github.com/graph-gophers/graphql-go/gqltesting"
9+
graphql "github.com/tokopedia/graphql-go"
10+
qerrors "github.com/tokopedia/graphql-go/errors"
11+
"github.com/tokopedia/graphql-go/gqltesting"
1212
)
1313

1414
type rootResolver struct {

0 commit comments

Comments
 (0)