github.com/weaviate/weaviate@v1.24.6/entities/models/graph_q_l_response.go (about) 1 // _ _ 2 // __ _____ __ ___ ___ __ _| |_ ___ 3 // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ 4 // \ V V / __/ (_| |\ V /| | (_| | || __/ 5 // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| 6 // 7 // Copyright © 2016 - 2024 Weaviate B.V. All rights reserved. 8 // 9 // CONTACT: hello@weaviate.io 10 // 11 12 // Code generated by go-swagger; DO NOT EDIT. 13 14 package models 15 16 // This file was generated by the swagger tool. 17 // Editing this file might prove futile when you re-run the swagger generate command 18 19 import ( 20 "context" 21 "strconv" 22 23 "github.com/go-openapi/errors" 24 "github.com/go-openapi/strfmt" 25 "github.com/go-openapi/swag" 26 ) 27 28 // GraphQLResponse GraphQL based response: http://facebook.github.io/graphql/. 29 // 30 // swagger:model GraphQLResponse 31 type GraphQLResponse struct { 32 33 // GraphQL data object. 34 Data map[string]JSONObject `json:"data,omitempty"` 35 36 // Array with errors. 37 Errors []*GraphQLError `json:"errors,omitempty"` 38 } 39 40 // Validate validates this graph q l response 41 func (m *GraphQLResponse) Validate(formats strfmt.Registry) error { 42 var res []error 43 44 if err := m.validateErrors(formats); err != nil { 45 res = append(res, err) 46 } 47 48 if len(res) > 0 { 49 return errors.CompositeValidationError(res...) 50 } 51 return nil 52 } 53 54 func (m *GraphQLResponse) validateErrors(formats strfmt.Registry) error { 55 if swag.IsZero(m.Errors) { // not required 56 return nil 57 } 58 59 for i := 0; i < len(m.Errors); i++ { 60 if swag.IsZero(m.Errors[i]) { // not required 61 continue 62 } 63 64 if m.Errors[i] != nil { 65 if err := m.Errors[i].Validate(formats); err != nil { 66 if ve, ok := err.(*errors.Validation); ok { 67 return ve.ValidateName("errors" + "." + strconv.Itoa(i)) 68 } else if ce, ok := err.(*errors.CompositeError); ok { 69 return ce.ValidateName("errors" + "." + strconv.Itoa(i)) 70 } 71 return err 72 } 73 } 74 75 } 76 77 return nil 78 } 79 80 // ContextValidate validate this graph q l response based on the context it is used 81 func (m *GraphQLResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 82 var res []error 83 84 if err := m.contextValidateErrors(ctx, formats); err != nil { 85 res = append(res, err) 86 } 87 88 if len(res) > 0 { 89 return errors.CompositeValidationError(res...) 90 } 91 return nil 92 } 93 94 func (m *GraphQLResponse) contextValidateErrors(ctx context.Context, formats strfmt.Registry) error { 95 96 for i := 0; i < len(m.Errors); i++ { 97 98 if m.Errors[i] != nil { 99 if err := m.Errors[i].ContextValidate(ctx, formats); err != nil { 100 if ve, ok := err.(*errors.Validation); ok { 101 return ve.ValidateName("errors" + "." + strconv.Itoa(i)) 102 } else if ce, ok := err.(*errors.CompositeError); ok { 103 return ce.ValidateName("errors" + "." + strconv.Itoa(i)) 104 } 105 return err 106 } 107 } 108 109 } 110 111 return nil 112 } 113 114 // MarshalBinary interface implementation 115 func (m *GraphQLResponse) MarshalBinary() ([]byte, error) { 116 if m == nil { 117 return nil, nil 118 } 119 return swag.WriteJSON(m) 120 } 121 122 // UnmarshalBinary interface implementation 123 func (m *GraphQLResponse) UnmarshalBinary(b []byte) error { 124 var res GraphQLResponse 125 if err := swag.ReadJSON(b, &res); err != nil { 126 return err 127 } 128 *m = res 129 return nil 130 }