graphql_introspection_generator.rb 645 B

123456789101112131415
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class Zammad::GraphqlIntrospectionGenerator < Rails::Generators::Base
  3. desc 'Create JSON from the GraphQL introspection information and output it to STDOUT'
  4. def generate
  5. result = Gql::ZammadSchema.execute(GraphQL::Introspection::INTROSPECTION_QUERY, variables: {}, context: { is_graphql_introspection_generator: true })
  6. raise "GraphQL schema could not be successfully generated: #{result['errors'].first['message']}" if result['errors']
  7. # rubocop:disable Rails/Output
  8. puts JSON.pretty_generate(result)
  9. # rubocop:enable Rails/Output
  10. end
  11. end