Skip to content

Commit

Permalink
Updated graph-gophers to tokopedia in import paths
Browse files Browse the repository at this point in the history
  • Loading branch information
abhif22 committed Aug 21, 2019
1 parent 7a5f606 commit d69a0b9
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 80 deletions.
2 changes: 1 addition & 1 deletion example/caching/caching.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"time"

"github.com/graph-gophers/graphql-go/example/caching/cache"
"github.com/tokopedia/graphql-go/example/caching/cache"
)

const Schema = `
Expand Down
6 changes: 3 additions & 3 deletions example/caching/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"log"
"net/http"

"github.com/graph-gophers/graphql-go"
"github.com/graph-gophers/graphql-go/example/caching"
"github.com/graph-gophers/graphql-go/example/caching/cache"
"github.com/tokopedia/graphql-go"
"github.com/tokopedia/graphql-go/example/caching"
"github.com/tokopedia/graphql-go/example/caching/cache"
)

var schema *graphql.Schema
Expand Down
6 changes: 3 additions & 3 deletions example/social/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"log"
"net/http"

"github.com/graph-gophers/graphql-go"
"github.com/graph-gophers/graphql-go/example/social"
"github.com/graph-gophers/graphql-go/relay"
"github.com/tokopedia/graphql-go"
"github.com/tokopedia/graphql-go/example/social"
"github.com/tokopedia/graphql-go/relay"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion example/social/social.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"time"

"github.com/graph-gophers/graphql-go"
"github.com/tokopedia/graphql-go"
)

const Schema = `
Expand Down
4 changes: 2 additions & 2 deletions gqltesting/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"strconv"
"testing"

graphql "github.com/graph-gophers/graphql-go"
"github.com/graph-gophers/graphql-go/errors"
graphql "github.com/tokopedia/graphql-go"
"github.com/tokopedia/graphql-go/errors"
)

// TestResponse models the expected response
Expand Down
8 changes: 4 additions & 4 deletions graphql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"testing"
"time"

"github.com/graph-gophers/graphql-go"
gqlerrors "github.com/graph-gophers/graphql-go/errors"
"github.com/graph-gophers/graphql-go/example/starwars"
"github.com/graph-gophers/graphql-go/gqltesting"
"github.com/tokopedia/graphql-go"
gqlerrors "github.com/tokopedia/graphql-go/errors"
"github.com/tokopedia/graphql-go/example/starwars"
"github.com/tokopedia/graphql-go/gqltesting"
)

type helloWorldResolver1 struct{}
Expand Down
45 changes: 2 additions & 43 deletions internal/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (r *Request) execSelections(ctx context.Context, sels []selected.Selection,
} else {
for _, f := range fields {
f.out = new(bytes.Buffer)
execFieldSelection(ctx, r, s, f, &pathSegment{path, f.field.Alias}, true)
execFieldSelection(ctx, r, f, &pathSegment{path, f.field.Alias}, true, fixedRes, fromFixedResp)
}
}

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

case *selected.TypenameField:
sf := &selected.SchemaField{
Field: s.Meta.FieldTypename,
// Field: resolvable.Meta,
Alias: sel.Alias,
FixedResult: reflect.ValueOf(typeOf(sel, resolver)),
}
Expand Down Expand Up @@ -453,47 +453,6 @@ func (r *Request) execSelectionSet(ctx context.Context, sels []selected.Selectio
}
}

func (r *Request) execList(ctx context.Context, sels []selected.Selection, typ *common.List, path *pathSegment, s *resolvable.Schema, resolver reflect.Value, out *bytes.Buffer) {

This comment has been minimized.

Copy link
@iwanbk

iwanbk Aug 26, 2019

I don't see we made any previous changes related to execList func.
It seems you remove it because it is not being used?
If yes, I suggest to remove it from the upstream repo, so we won't face any conflict in the future.

l := resolver.Len()
entryouts := make([]bytes.Buffer, l)

if selected.HasAsyncSel(sels) {
var wg sync.WaitGroup
wg.Add(l)
for i := 0; i < l; i++ {
go func(i int) {
defer wg.Done()
defer r.handlePanic(ctx)
r.execSelectionSet(ctx, sels, typ.OfType, &pathSegment{path, i}, s, resolver.Index(i), &entryouts[i])
}(i)
}
wg.Wait()
} else {
for i := 0; i < l; i++ {
r.execSelectionSet(ctx, sels, typ.OfType, &pathSegment{path, i}, s, resolver.Index(i), &entryouts[i])
}
}

_, listOfNonNull := typ.OfType.(*common.NonNull)

out.WriteByte('[')
for i, entryout := range entryouts {
// If the list wraps a non-null type and one of the list elements
// resolves to null, then the entire list resolves to null.
if listOfNonNull && resolvedToNull(&entryout) {
out.Reset()
out.WriteString("null")
return
}

if i > 0 {
out.WriteByte(',')
}
out.Write(entryout.Bytes())
}
out.WriteByte(']')
}

func unwrapNonNull(t common.Type) (common.Type, bool) {
if nn, ok := t.(*common.NonNull); ok {
return nn.OfType, true
Expand Down
21 changes: 12 additions & 9 deletions internal/exec/subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"reflect"
"time"

"github.com/graph-gophers/graphql-go/errors"
"github.com/graph-gophers/graphql-go/internal/common"
"github.com/graph-gophers/graphql-go/internal/exec/resolvable"
"github.com/graph-gophers/graphql-go/internal/exec/selected"
"github.com/graph-gophers/graphql-go/internal/query"
"github.com/tokopedia/graphql-go/errors"
"github.com/tokopedia/graphql-go/internal/common"
"github.com/tokopedia/graphql-go/internal/exec/resolvable"
"github.com/tokopedia/graphql-go/internal/exec/selected"
"github.com/tokopedia/graphql-go/internal/query"
)

type Response struct {
Expand All @@ -24,13 +24,13 @@ func (r *Request) Subscribe(ctx context.Context, s *resolvable.Schema, op *query
var result reflect.Value
var f *fieldToExec
var err *errors.QueryError
var fromFixedResponse bool
func() {
defer r.handlePanic(ctx)

sels := selected.ApplyOperation(&r.Request, s, op)
var fields []*fieldToExec
collectFieldsToResolve(sels, s, s.Resolver, &fields, make(map[string]*fieldToExec))

collectFieldsToResolve(sels, s.Resolver, &fields, make(map[string]*fieldToExec), &fromFixedResponse)
// TODO: move this check into validation.Validate
if len(fields) != 1 {
err = errors.Errorf("%s", "can subscribe to at most one subscription at a time")
Expand Down Expand Up @@ -118,9 +118,12 @@ func (r *Request) Subscribe(ctx context.Context, s *resolvable.Schema, op *query
// resolve response
func() {
defer subR.handlePanic(subCtx)

var (
fixedRes interface{}
fromFixedResp bool
)
var buf bytes.Buffer
subR.execSelectionSet(subCtx, f.sels, f.field.Type, &pathSegment{nil, f.field.Alias}, s, resp, &buf)
subR.execSelectionSet(subCtx, f.sels, f.field.Type, &pathSegment{nil, f.field.Alias}, resp, &buf, fixedRes, &fromFixedResp)

propagateChildError := false
if _, nonNullChild := f.field.Type.(*common.NonNull); nonNullChild && resolvedToNull(&buf) {
Expand Down
6 changes: 3 additions & 3 deletions introspection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"io/ioutil"
"testing"

"github.com/graph-gophers/graphql-go"
"github.com/graph-gophers/graphql-go/example/social"
"github.com/graph-gophers/graphql-go/example/starwars"
"github.com/tokopedia/graphql-go"
"github.com/tokopedia/graphql-go/example/social"
"github.com/tokopedia/graphql-go/example/starwars"
)

func TestSchema_ToJSON(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"errors"
"testing"

graphql "github.com/graph-gophers/graphql-go"
qerrors "github.com/graph-gophers/graphql-go/errors"
"github.com/graph-gophers/graphql-go/gqltesting"
graphql "github.com/tokopedia/graphql-go"
qerrors "github.com/tokopedia/graphql-go/errors"
"github.com/tokopedia/graphql-go/gqltesting"
)

type rootResolver struct {
Expand Down
16 changes: 8 additions & 8 deletions subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"errors"
"reflect"

qerrors "github.com/graph-gophers/graphql-go/errors"
"github.com/graph-gophers/graphql-go/internal/common"
"github.com/graph-gophers/graphql-go/internal/exec"
"github.com/graph-gophers/graphql-go/internal/exec/resolvable"
"github.com/graph-gophers/graphql-go/internal/exec/selected"
"github.com/graph-gophers/graphql-go/internal/query"
"github.com/graph-gophers/graphql-go/internal/validation"
"github.com/graph-gophers/graphql-go/introspection"
qerrors "github.com/tokopedia/graphql-go/errors"
"github.com/tokopedia/graphql-go/internal/common"
"github.com/tokopedia/graphql-go/internal/exec"
"github.com/tokopedia/graphql-go/internal/exec/resolvable"
"github.com/tokopedia/graphql-go/internal/exec/selected"
"github.com/tokopedia/graphql-go/internal/query"
"github.com/tokopedia/graphql-go/internal/validation"
"github.com/tokopedia/graphql-go/introspection"
)

// Subscribe returns a response channel for the given subscription with the schema's
Expand Down

0 comments on commit d69a0b9

Please sign in to comment.