Class: MockServer::GraphQLBody
- Inherits:
-
Object
- Object
- MockServer::GraphQLBody
- Defined in:
- lib/mockserver/models.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
selection_set_match_type selects how the query's selection set is matched (NORMALISED_STRING / AST_EXACT / AST_SUBSET) and
fieldsis the array of top-level field names the matcher restricts to, mirroring the server GraphQLBodyDTOselectionSetMatchType/fields(the GRAPHQL body'sfieldsis a plain string array, distinct from the MULTIPART body's keyToMultiValuefieldsmap — the server discriminates the two by the bodytype). -
#not_body ⇒ Object
selection_set_match_type selects how the query's selection set is matched (NORMALISED_STRING / AST_EXACT / AST_SUBSET) and
fieldsis the array of top-level field names the matcher restricts to, mirroring the server GraphQLBodyDTOselectionSetMatchType/fields(the GRAPHQL body'sfieldsis a plain string array, distinct from the MULTIPART body's keyToMultiValuefieldsmap — the server discriminates the two by the bodytype). -
#operation_name ⇒ Object
selection_set_match_type selects how the query's selection set is matched (NORMALISED_STRING / AST_EXACT / AST_SUBSET) and
fieldsis the array of top-level field names the matcher restricts to, mirroring the server GraphQLBodyDTOselectionSetMatchType/fields(the GRAPHQL body'sfieldsis a plain string array, distinct from the MULTIPART body's keyToMultiValuefieldsmap — the server discriminates the two by the bodytype). -
#optional ⇒ Object
selection_set_match_type selects how the query's selection set is matched (NORMALISED_STRING / AST_EXACT / AST_SUBSET) and
fieldsis the array of top-level field names the matcher restricts to, mirroring the server GraphQLBodyDTOselectionSetMatchType/fields(the GRAPHQL body'sfieldsis a plain string array, distinct from the MULTIPART body's keyToMultiValuefieldsmap — the server discriminates the two by the bodytype). -
#query ⇒ Object
selection_set_match_type selects how the query's selection set is matched (NORMALISED_STRING / AST_EXACT / AST_SUBSET) and
fieldsis the array of top-level field names the matcher restricts to, mirroring the server GraphQLBodyDTOselectionSetMatchType/fields(the GRAPHQL body'sfieldsis a plain string array, distinct from the MULTIPART body's keyToMultiValuefieldsmap — the server discriminates the two by the bodytype). -
#selection_set_match_type ⇒ Object
selection_set_match_type selects how the query's selection set is matched (NORMALISED_STRING / AST_EXACT / AST_SUBSET) and
fieldsis the array of top-level field names the matcher restricts to, mirroring the server GraphQLBodyDTOselectionSetMatchType/fields(the GRAPHQL body'sfieldsis a plain string array, distinct from the MULTIPART body's keyToMultiValuefieldsmap — the server discriminates the two by the bodytype). -
#variables_schema ⇒ Object
selection_set_match_type selects how the query's selection set is matched (NORMALISED_STRING / AST_EXACT / AST_SUBSET) and
fieldsis the array of top-level field names the matcher restricts to, mirroring the server GraphQLBodyDTOselectionSetMatchType/fields(the GRAPHQL body'sfieldsis a plain string array, distinct from the MULTIPART body's keyToMultiValuefieldsmap — the server discriminates the two by the bodytype).
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(query:, operation_name: nil, variables_schema: nil, selection_set_match_type: nil, fields: nil, not_body: false, optional: false) ⇒ GraphQLBody
constructor
A new instance of GraphQLBody.
- #to_h ⇒ Object
Constructor Details
#initialize(query:, operation_name: nil, variables_schema: nil, selection_set_match_type: nil, fields: nil, not_body: false, optional: false) ⇒ GraphQLBody
Returns a new instance of GraphQLBody.
664 665 666 667 668 669 670 671 672 673 |
# File 'lib/mockserver/models.rb', line 664 def initialize(query:, operation_name: nil, variables_schema: nil, selection_set_match_type: nil, fields: nil, not_body: false, optional: false) @query = query @operation_name = operation_name @variables_schema = variables_schema @selection_set_match_type = selection_set_match_type @fields = fields @not_body = not_body @optional = optional end |
Instance Attribute Details
#fields ⇒ Object
selection_set_match_type selects how the query's selection set is matched
(NORMALISED_STRING / AST_EXACT / AST_SUBSET) and fields is the array of
top-level field names the matcher restricts to, mirroring the server
GraphQLBodyDTO selectionSetMatchType / fields (the GRAPHQL body's fields
is a plain string array, distinct from the MULTIPART body's keyToMultiValue
fields map — the server discriminates the two by the body type).
661 662 663 |
# File 'lib/mockserver/models.rb', line 661 def fields @fields end |
#not_body ⇒ Object
selection_set_match_type selects how the query's selection set is matched
(NORMALISED_STRING / AST_EXACT / AST_SUBSET) and fields is the array of
top-level field names the matcher restricts to, mirroring the server
GraphQLBodyDTO selectionSetMatchType / fields (the GRAPHQL body's fields
is a plain string array, distinct from the MULTIPART body's keyToMultiValue
fields map — the server discriminates the two by the body type).
661 662 663 |
# File 'lib/mockserver/models.rb', line 661 def not_body @not_body end |
#operation_name ⇒ Object
selection_set_match_type selects how the query's selection set is matched
(NORMALISED_STRING / AST_EXACT / AST_SUBSET) and fields is the array of
top-level field names the matcher restricts to, mirroring the server
GraphQLBodyDTO selectionSetMatchType / fields (the GRAPHQL body's fields
is a plain string array, distinct from the MULTIPART body's keyToMultiValue
fields map — the server discriminates the two by the body type).
661 662 663 |
# File 'lib/mockserver/models.rb', line 661 def operation_name @operation_name end |
#optional ⇒ Object
selection_set_match_type selects how the query's selection set is matched
(NORMALISED_STRING / AST_EXACT / AST_SUBSET) and fields is the array of
top-level field names the matcher restricts to, mirroring the server
GraphQLBodyDTO selectionSetMatchType / fields (the GRAPHQL body's fields
is a plain string array, distinct from the MULTIPART body's keyToMultiValue
fields map — the server discriminates the two by the body type).
661 662 663 |
# File 'lib/mockserver/models.rb', line 661 def optional @optional end |
#query ⇒ Object
selection_set_match_type selects how the query's selection set is matched
(NORMALISED_STRING / AST_EXACT / AST_SUBSET) and fields is the array of
top-level field names the matcher restricts to, mirroring the server
GraphQLBodyDTO selectionSetMatchType / fields (the GRAPHQL body's fields
is a plain string array, distinct from the MULTIPART body's keyToMultiValue
fields map — the server discriminates the two by the body type).
661 662 663 |
# File 'lib/mockserver/models.rb', line 661 def query @query end |
#selection_set_match_type ⇒ Object
selection_set_match_type selects how the query's selection set is matched
(NORMALISED_STRING / AST_EXACT / AST_SUBSET) and fields is the array of
top-level field names the matcher restricts to, mirroring the server
GraphQLBodyDTO selectionSetMatchType / fields (the GRAPHQL body's fields
is a plain string array, distinct from the MULTIPART body's keyToMultiValue
fields map — the server discriminates the two by the body type).
661 662 663 |
# File 'lib/mockserver/models.rb', line 661 def selection_set_match_type @selection_set_match_type end |
#variables_schema ⇒ Object
selection_set_match_type selects how the query's selection set is matched
(NORMALISED_STRING / AST_EXACT / AST_SUBSET) and fields is the array of
top-level field names the matcher restricts to, mirroring the server
GraphQLBodyDTO selectionSetMatchType / fields (the GRAPHQL body's fields
is a plain string array, distinct from the MULTIPART body's keyToMultiValue
fields map — the server discriminates the two by the body type).
661 662 663 |
# File 'lib/mockserver/models.rb', line 661 def variables_schema @variables_schema end |
Class Method Details
.from_hash(data) ⇒ Object
686 687 688 689 690 691 692 693 694 695 696 697 698 |
# File 'lib/mockserver/models.rb', line 686 def self.from_hash(data) return nil if data.nil? new( query: data['query'] || '', operation_name: data['operationName'], variables_schema: data['variablesSchema'], selection_set_match_type: data['selectionSetMatchType'], fields: data['fields'], not_body: data.fetch('not', false), optional: data.fetch('optional', false) ) end |
Instance Method Details
#to_h ⇒ Object
675 676 677 678 679 680 681 682 683 684 |
# File 'lib/mockserver/models.rb', line 675 def to_h result = { 'type' => 'GRAPHQL', 'query' => @query } result['operationName'] = @operation_name if @operation_name result['variablesSchema'] = @variables_schema if @variables_schema result['selectionSetMatchType'] = @selection_set_match_type unless @selection_set_match_type.nil? result['fields'] = @fields unless @fields.nil? result['not'] = true if @not_body result['optional'] = true if @optional result end |