diff --git a/app/graphql/types/embed/article_embed.rb b/app/graphql/types/embed/article_embed.rb new file mode 100644 index 0000000000..082f0941a2 --- /dev/null +++ b/app/graphql/types/embed/article_embed.rb @@ -0,0 +1,3 @@ +class Types::Embed::WebsiteEmbed < Types::BaseObject + implements Types::Interface::BaseEmbed +end \ No newline at end of file diff --git a/app/graphql/types/embed/audio_tag_embed.rb b/app/graphql/types/embed/audio_tag_embed.rb new file mode 100644 index 0000000000..dad8474f09 --- /dev/null +++ b/app/graphql/types/embed/audio_tag_embed.rb @@ -0,0 +1,5 @@ +class Types::Embed::AudioTagEmbed < Types::BaseObject + implements Types::Interface::BaseTagEmbed + + description 'Audio Properties' +end \ No newline at end of file diff --git a/app/graphql/types/embed/book_embed.rb b/app/graphql/types/embed/book_embed.rb new file mode 100644 index 0000000000..9ed4946cdc --- /dev/null +++ b/app/graphql/types/embed/book_embed.rb @@ -0,0 +1,3 @@ +class Types::Embed::BookEmbed < Types::BaseObject + implements Types::Interface::BaseEmbed +end \ No newline at end of file diff --git a/app/graphql/types/embed/image_embed.rb b/app/graphql/types/embed/image_embed.rb new file mode 100644 index 0000000000..177bff0a1f --- /dev/null +++ b/app/graphql/types/embed/image_embed.rb @@ -0,0 +1,3 @@ +class Types::Embed::ImageEmbed < Types::BaseObject + implements Types::Interface::BaseEmbed +end \ No newline at end of file diff --git a/app/graphql/types/embed/image_tag_embed.rb b/app/graphql/types/embed/image_tag_embed.rb new file mode 100644 index 0000000000..a40e0aadfa --- /dev/null +++ b/app/graphql/types/embed/image_tag_embed.rb @@ -0,0 +1,17 @@ +class Types::Embed::ImageTagEmbed < Types::BaseObject + implements Types::Interface::BaseTagEmbed + + description 'Image Properties' + + field :width, String, + null: false, + description: 'The number of pixels wide.' + + field :height, String, + null: false, + description: 'The number of pixels high.' + + field :alt, String, + null: false, + description: 'A description of what is in the image (not a caption).' +end diff --git a/app/graphql/types/embed/music_embed.rb b/app/graphql/types/embed/music_embed.rb new file mode 100644 index 0000000000..32a5188587 --- /dev/null +++ b/app/graphql/types/embed/music_embed.rb @@ -0,0 +1,4 @@ +class Types::Embed::MusicEmbed < Types::BaseObject + implements Types::Interface::BaseEmbed + +end \ No newline at end of file diff --git a/app/graphql/types/embed/profile_embed.rb b/app/graphql/types/embed/profile_embed.rb new file mode 100644 index 0000000000..ef27b5c86c --- /dev/null +++ b/app/graphql/types/embed/profile_embed.rb @@ -0,0 +1,22 @@ +class Types::Embed::WebsiteEmbed < Types::BaseObject + implements Types::Interface::BaseEmbed + + field :first_name, String, + null: true, + description: 'A name normally given to an individual by a parent or self-chosen.' + + field :last_name, String, + null: true, + description: <<~DESCRIPTION.squish + A name inherited from a family or marriage + and by which the individual is commonly known. + DESCRIPTION + + field :username, String, + null: true, + description: 'A short unique string to identify them.' + + field :gender, Types::Enum::Gender, + null: true, + description: 'Their gender.' +end \ No newline at end of file diff --git a/app/graphql/types/embed/video_embed.rb b/app/graphql/types/embed/video_embed.rb new file mode 100644 index 0000000000..d1e9cd7463 --- /dev/null +++ b/app/graphql/types/embed/video_embed.rb @@ -0,0 +1,4 @@ +class Types::Embed::VideoEmbed < Types::BaseObject + implements Types::Interface::BaseEmbed + +end \ No newline at end of file diff --git a/app/graphql/types/embed/video_tag_embed.rb b/app/graphql/types/embed/video_tag_embed.rb new file mode 100644 index 0000000000..554e30daeb --- /dev/null +++ b/app/graphql/types/embed/video_tag_embed.rb @@ -0,0 +1,17 @@ +class Types::Embed::VideoTagEmbed < Types::BaseObject + implements Types::Interface::BaseTagEmbed + + description 'Video Properties' + + field :width, String, + null: false, + description: 'The number of pixels wide.' + + field :height, String, + null: false, + description: 'The number of pixels high.' + + field :alt, String, + null: false, + description: 'A description of what is in the video (not a caption).' +end diff --git a/app/graphql/types/embed/website_embed.rb b/app/graphql/types/embed/website_embed.rb new file mode 100644 index 0000000000..082f0941a2 --- /dev/null +++ b/app/graphql/types/embed/website_embed.rb @@ -0,0 +1,3 @@ +class Types::Embed::WebsiteEmbed < Types::BaseObject + implements Types::Interface::BaseEmbed +end \ No newline at end of file diff --git a/app/graphql/types/enum/gender.rb b/app/graphql/types/enum/gender.rb new file mode 100644 index 0000000000..fe885b7a11 --- /dev/null +++ b/app/graphql/types/enum/gender.rb @@ -0,0 +1,5 @@ +class Types::Enum::Gender < Types::Enum::Base + value 'MALE', value: 'male' + value 'FEMALE', value: 'female' + value 'OTHER', value: 'other' +end \ No newline at end of file diff --git a/app/graphql/types/interface/base_embed.rb b/app/graphql/types/interface/base_embed.rb new file mode 100644 index 0000000000..c9c8eaab87 --- /dev/null +++ b/app/graphql/types/interface/base_embed.rb @@ -0,0 +1,69 @@ +module Types::Interface::BaseEmbed + include Types::Interface::Base + description 'Required and Optional fields for an Embed based off the Open Graph protocol' + + orphan_types Types::Embed::WebsiteEmbed + + field :title, String, + null: false, + description: 'The title of your object as it should appear within the graph.' + + field :kind, String, + null: false, + description: <<~DESCRIPTION.squish + The type of your object, + e.g., "video.movie". + Depending on the type you specify, other properties may also be required. + DESCRIPTION + + field :url, String, + null: false, + description: 'The canonical URL of your object that will be used as its permanent ID in the graph' + + field :image, Types::Embed::ImageTagEmbed, + null: false, + description: 'An image URL which should represent your object within the graph.' + + field :audio, Types::Embed::AudioTagEmbed, + null: true, + description: 'A URL to an audio file to accompany this object.' + + field :description, String, + null: true, + description: 'A one to two sentence description of your object.' + + field :determiner, String, + null: true, + description: <<~DESCRIPTION.squish + The word that appears before this object's title in a sentence. + An enum of (a, an, the, "", auto). If auto is chosen, + the consumer of your data should chose between "a" or "an". Default is "" (blank). + DESCRIPTION + + field :locale, String, + null: true, + description: <<~DESCRIPTION.squish + The locale these tags are marked up in. + Of the format language_territory. + Default is en_us. + DESCRIPTION + + field :locale_alternative, [String], + null: true, + description: 'An array of other locales this page is available in.' + + field :site, String, + null: true, + description: '' + + field :site_name, String, + null: true, + description: <<~DESCRIPTION.squish + If your object is part of a larger web site, + the name which should be displayed for the overall site. + DESCRIPTION + + field :video, Types::Embed::VideoTagEmbed, + null: true, + description: 'A URL to a video file that complements this object.' +end diff --git a/app/graphql/types/interface/base_tag_embed.rb b/app/graphql/types/interface/base_tag_embed.rb new file mode 100644 index 0000000000..1ee754e587 --- /dev/null +++ b/app/graphql/types/interface/base_tag_embed.rb @@ -0,0 +1,17 @@ +module Types::Interface::BaseTagEmbed + include Types::Interface::Base + + description 'Similar fields between Image, Audio, Video Tags.' + + field :url, String, + null: false, + description: 'A url.' + + field :secure_url, String, + null: true, + description: 'An alternate url to use if the webpage requires HTTPS.' + + field :kind, String, + null: true, + description: 'A MIME type' +end diff --git a/app/graphql/types/post.rb b/app/graphql/types/post.rb index 445f5ff5e2..cfd53a3bb4 100644 --- a/app/graphql/types/post.rb +++ b/app/graphql/types/post.rb @@ -44,6 +44,10 @@ class Types::Post < Types::BaseObject null: true, description: 'The reason why this post was locked.' + field :embed, Types::Interface::BaseEmbed, + null: true, + description: '' + field :comments, Types::Comment.connection_type, null: false, description: 'All comments related to this post.'