Sha256: 36710f7f9ea3d607752c7904b31de4eaf2f2c40e08a61d7cce8324b455d7b103

Contents?: true

Size: 518 Bytes

Versions: 1

Compression:

Stored size: 518 Bytes

Contents

require 'mock_graphql_ai/version'

module MockGraphqlAi
  def self.add_mock_result_assignment(controller_file_path)
    file_contents = File.read(controller_file_path)
    modified_contents = file_contents.gsub(
      /(result\s*=\s*)GraphqlBoilerplateSchema\.execute\(query, variables: variables, context: @context, operation_name: operation_name\)/m,
      "result = ENV['GRAPHQL_MOCK_MODE'] ? Mocks::Resource.new({ query: query }).call : \\0"
    )

    File.write(controller_file_path, modified_contents)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mock_graphql_ai-1.0.1 lib/mock_graphql_ai.rb