Class: Mcp::Tools::GraphqlTool
- Inherits:
-
Object
- Object
- Mcp::Tools::GraphqlTool
- Includes:
- Concerns::Versionable
- Defined in:
- app/services/mcp/tools/graphql_tool.rb
Direct Known Subclasses
Constant Summary
Constants included from Concerns::Versionable
Concerns::Versionable::VERSION_FORMAT
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#build_variables ⇒ Object
Can be overridden with version-specific methods.
- #execute ⇒ Object
-
#graphql_operation ⇒ Object
Override in subclasses or use version metadata.
-
#initialize(current_user:, params:, version: nil) ⇒ GraphqlTool
constructor
A new instance of GraphqlTool.
- #operation_name ⇒ Object
Methods included from Concerns::Versionable
#description, #initialize_version, #input_schema, #version
Constructor Details
#initialize(current_user:, params:, version: nil) ⇒ GraphqlTool
Returns a new instance of GraphqlTool.
10 11 12 13 14 |
# File 'app/services/mcp/tools/graphql_tool.rb', line 10 def initialize(current_user:, params:, version: nil) @current_user = current_user @params = params initialize_version(version) end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
8 9 10 |
# File 'app/services/mcp/tools/graphql_tool.rb', line 8 def current_user @current_user end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
8 9 10 |
# File 'app/services/mcp/tools/graphql_tool.rb', line 8 def params @params end |
Instance Method Details
#build_variables ⇒ Object
Can be overridden with version-specific methods
29 30 31 |
# File 'app/services/mcp/tools/graphql_tool.rb', line 29 def build_variables raise NotImplementedError, "build_variables must be implemented" end |
#execute ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'app/services/mcp/tools/graphql_tool.rb', line 33 def execute result = GitlabSchema.execute( graphql_operation_for_version, variables: build_variables_for_version, context: execution_context ) process_result(result) end |
#graphql_operation ⇒ Object
Override in subclasses or use version metadata
17 18 19 20 21 |
# File 'app/services/mcp/tools/graphql_tool.rb', line 17 def graphql_operation raise NotImplementedError unless self.class.(version)[:graphql_operation] self.class.(version)[:graphql_operation] end |
#operation_name ⇒ Object
23 24 25 26 |
# File 'app/services/mcp/tools/graphql_tool.rb', line 23 def operation_name self.class.(version)[:operation_name] || raise(NotImplementedError, "operation_name must be defined") end |