Commit 695def36 authored by Matija Čupić's avatar Matija Čupić

Add UserCallout GraphQL type

Creates the UserCallout GraphQL type
parent 0a2e826a
# frozen_string_literal: true
module Types
class UserCalloutFeatureNameEnum < BaseEnum
graphql_name 'UserCalloutFeatureNameEnum'
description 'Name of the feature that the callout is for'
::UserCallout.feature_names.keys.each do |feature_name|
value feature_name.upcase, value: feature_name
end
end
end
# frozen_string_literal: true
module Types
# rubocop:disable Graphql/AuthorizeTypes
class UserCalloutType < BaseObject
graphql_name 'UserCallout'
field :feature_name, UserCalloutFeatureNameEnum, null: false,
description: 'Name of the feature that the callout is for.'
field :dismissed_at, Types::TimeType, null: true,
description: 'Date when the callout was dismissed.'
end
# rubocop:enable Graphql/AuthorizeTypes
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GitlabSchema.types['UserCalloutFeatureNameEnum'] do
specify { expect(described_class.graphql_name).to eq('UserCalloutFeatureNameEnum') }
it 'exposes all the existing user callout feature names' do
expect(described_class.values.keys).to match_array(::UserCallout.feature_names.keys.map(&:upcase))
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GitlabSchema.types['UserCallout'] do
specify { expect(described_class.graphql_name).to eq('UserCallout') }
it 'has expected fields' do
expect(described_class).to have_graphql_fields(:feature_name, :dismissed_at)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment