| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
|
|
| package graphql |
|
|
| |
| |
|
|
| import ( |
| "fmt" |
|
|
| "github.com/go-openapi/runtime" |
| "github.com/go-openapi/strfmt" |
| ) |
|
|
| |
| func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { |
| return &Client{transport: transport, formats: formats} |
| } |
|
|
| |
| |
| |
| type Client struct { |
| transport runtime.ClientTransport |
| formats strfmt.Registry |
| } |
|
|
| |
| type ClientOption func(*runtime.ClientOperation) |
|
|
| |
| type ClientService interface { |
| GraphqlBatch(params *GraphqlBatchParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GraphqlBatchOK, error) |
|
|
| GraphqlPost(params *GraphqlPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GraphqlPostOK, error) |
|
|
| SetTransport(transport runtime.ClientTransport) |
| } |
|
|
| |
| |
| |
| |
| |
| func (a *Client) GraphqlBatch(params *GraphqlBatchParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GraphqlBatchOK, error) { |
| |
| if params == nil { |
| params = NewGraphqlBatchParams() |
| } |
| op := &runtime.ClientOperation{ |
| ID: "graphql.batch", |
| Method: "POST", |
| PathPattern: "/graphql/batch", |
| ProducesMediaTypes: []string{"application/json"}, |
| ConsumesMediaTypes: []string{"application/json", "application/yaml"}, |
| Schemes: []string{"https"}, |
| Params: params, |
| Reader: &GraphqlBatchReader{formats: a.formats}, |
| AuthInfo: authInfo, |
| Context: params.Context, |
| Client: params.HTTPClient, |
| } |
| for _, opt := range opts { |
| opt(op) |
| } |
|
|
| result, err := a.transport.Submit(op) |
| if err != nil { |
| return nil, err |
| } |
| success, ok := result.(*GraphqlBatchOK) |
| if ok { |
| return success, nil |
| } |
| |
| |
| msg := fmt.Sprintf("unexpected success response for graphql.batch: API contract not enforced by server. Client expected to get an error, but got: %T", result) |
| panic(msg) |
| } |
|
|
| |
| |
| |
| |
| |
| func (a *Client) GraphqlPost(params *GraphqlPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GraphqlPostOK, error) { |
| |
| if params == nil { |
| params = NewGraphqlPostParams() |
| } |
| op := &runtime.ClientOperation{ |
| ID: "graphql.post", |
| Method: "POST", |
| PathPattern: "/graphql", |
| ProducesMediaTypes: []string{"application/json"}, |
| ConsumesMediaTypes: []string{"application/json", "application/yaml"}, |
| Schemes: []string{"https"}, |
| Params: params, |
| Reader: &GraphqlPostReader{formats: a.formats}, |
| AuthInfo: authInfo, |
| Context: params.Context, |
| Client: params.HTTPClient, |
| } |
| for _, opt := range opts { |
| opt(op) |
| } |
|
|
| result, err := a.transport.Submit(op) |
| if err != nil { |
| return nil, err |
| } |
| success, ok := result.(*GraphqlPostOK) |
| if ok { |
| return success, nil |
| } |
| |
| |
| msg := fmt.Sprintf("unexpected success response for graphql.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) |
| panic(msg) |
| } |
|
|
| |
| func (a *Client) SetTransport(transport runtime.ClientTransport) { |
| a.transport = transport |
| } |
|
|