Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL - Embeds #898

Open
wants to merge 10 commits into
base: the-future
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/graphql/types/embed/article_embed.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Types::Embed::WebsiteEmbed < Types::BaseObject
implements Types::Interface::BaseEmbed
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final newline missing. (https://rubystyle.guide#newline-eof)

5 changes: 5 additions & 0 deletions app/graphql/types/embed/audio_tag_embed.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Types::Embed::AudioTagEmbed < Types::BaseObject
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the Tag?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seemed kind of strange just being AudioEmbed and on the docs it used tag in the description. i.e: The og:video tag has the identical tags which I kinda liked. I can rename though.

implements Types::Interface::BaseTagEmbed

description 'Audio Properties'
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final newline missing. (https://rubystyle.guide#newline-eof)

3 changes: 3 additions & 0 deletions app/graphql/types/embed/book_embed.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Types::Embed::BookEmbed < Types::BaseObject
implements Types::Interface::BaseEmbed
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final newline missing. (https://rubystyle.guide#newline-eof)

3 changes: 3 additions & 0 deletions app/graphql/types/embed/image_embed.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Types::Embed::ImageEmbed < Types::BaseObject
implements Types::Interface::BaseEmbed
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final newline missing. (https://rubystyle.guide#newline-eof)

17 changes: 17 additions & 0 deletions app/graphql/types/embed/image_tag_embed.rb
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions app/graphql/types/embed/music_embed.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Types::Embed::MusicEmbed < Types::BaseObject
implements Types::Interface::BaseEmbed

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at class body end. (https://rubystyle.guide#empty-lines-around-bodies)

end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final newline missing. (https://rubystyle.guide#newline-eof)

22 changes: 22 additions & 0 deletions app/graphql/types/embed/profile_embed.rb
Original file line number Diff line number Diff line change
@@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final newline missing. (https://rubystyle.guide#newline-eof)

4 changes: 4 additions & 0 deletions app/graphql/types/embed/video_embed.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Types::Embed::VideoEmbed < Types::BaseObject
implements Types::Interface::BaseEmbed

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at class body end. (https://rubystyle.guide#empty-lines-around-bodies)

end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final newline missing. (https://rubystyle.guide#newline-eof)

17 changes: 17 additions & 0 deletions app/graphql/types/embed/video_tag_embed.rb
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions app/graphql/types/embed/website_embed.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Types::Embed::WebsiteEmbed < Types::BaseObject
implements Types::Interface::BaseEmbed
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final newline missing. (https://rubystyle.guide#newline-eof)

5 changes: 5 additions & 0 deletions app/graphql/types/enum/gender.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Types::Enum::Gender < Types::Enum::Base
value 'MALE', value: 'male'
value 'FEMALE', value: 'female'
value 'OTHER', value: 'other'
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final newline missing. (https://rubystyle.guide#newline-eof)

69 changes: 69 additions & 0 deletions app/graphql/types/interface/base_embed.rb
Original file line number Diff line number Diff line change
@@ -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'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [102/100] (https://rubystyle.guide#80-character-limits)


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.'
Comment on lines +35 to +53
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we use any of these

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we not start bringing them in? They are optional.


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
17 changes: 17 additions & 0 deletions app/graphql/types/interface/base_tag_embed.rb
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions app/graphql/types/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down