-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathgraphql_client.go
31 lines (24 loc) · 967 Bytes
/
graphql_client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package appsync
import (
"context"
"net/http"
"github.com/sony/appsync-client-go/graphql"
)
// GraphQLClient is the interface to access GraphQL server.
type GraphQLClient interface {
Post(header http.Header, request graphql.PostRequest) (*graphql.Response, error)
PostAsync(header http.Header, request graphql.PostRequest, callback func(*graphql.Response, error)) (context.CancelFunc, error)
}
type graphQLClient struct {
client *graphql.Client
}
// NewGraphQLClient returns a GraphQLClient interface
func NewGraphQLClient(client *graphql.Client) GraphQLClient {
return &graphQLClient{client}
}
func (d *graphQLClient) Post(header http.Header, request graphql.PostRequest) (*graphql.Response, error) {
return d.client.Post(header, request)
}
func (d *graphQLClient) PostAsync(header http.Header, request graphql.PostRequest, callback func(*graphql.Response, error)) (context.CancelFunc, error) {
return d.client.PostAsync(header, request, callback)
}