-
Notifications
You must be signed in to change notification settings - Fork 141
GraphQL - Embeds #898
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
base: the-future
Are you sure you want to change the base?
GraphQL - Embeds #898
Changes from 1 commit
34e0d65
a04db9d
9424ba9
913b1c4
7d4a713
cc45c46
9fb779b
65ef417
ef6c4c9
5e9c522
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module OptionalEmbedDescription | ||
| extend ActiveSupport::Concern | ||
|
|
||
| AUDIO_DESCRIPTION = 'A URL to an audio file to accompany this object.' | ||
| DESCRIPTION = 'A one to two sentence description of your object.' | ||
| DETERMINER_DESCRIPTION = %q[ | ||
| 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). | ||
| ] | ||
| LOCALE_DESCRIPTION = %[ | ||
| The locale these tags are marked up in. | ||
| Of the format language_TERRITORY. Default is en_US. | ||
| ] | ||
| LOCALE_ALTERNATIVE_DESCRIPTION = 'An array of other locales this page is available in.' | ||
| SITE_NAME_DESCRIPTION = %[ | ||
| If your object is part of a larger web site, | ||
| the name which should be displayed for the overall site. | ||
| ] | ||
| VIDEO_DESCRIPTION = 'A URL to a video file that complements this object.' | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class Types::Embed::WebsiteEmbed < Types::BaseObject | ||
| include OptionalEmbedDescription | ||
| implements Types::Interface::RequiredEmbed | ||
|
|
||
| field :site_name, String, | ||
| description: SITE_NAME_DESCRIPTION, | ||
| null: false | ||
| end | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Final newline missing. (https://rubystyle.guide#newline-eof) |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| module Types::Interface::RequiredEmbed | ||
|
toyhammered marked this conversation as resolved.
Outdated
|
||
| include Types::Interface::Base | ||
| description 'Required fields for an Embed based off the Open Graph protocol' | ||
|
|
||
| field :title, String, | ||
| null: true, | ||
| description: '' | ||
|
|
||
| field :kind, String, | ||
| null: false, | ||
| description: '' | ||
|
|
||
| field :description, String, | ||
| null: true, | ||
| description: '' | ||
|
|
||
| field :site, String, | ||
| null: true, | ||
| description: '' | ||
|
|
||
| field :url, String, | ||
| null: true, | ||
| description: '' | ||
|
|
||
| # field :image, Types::EmbedImage, | ||
| # null: true, | ||
| # description: '' | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| class Types::Union::EmbedItem < Types::Union::Base | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a good argument to using a union vs just referencing the base embed interface that all embeds inherit from?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not actually sure. I've always preferred using a union vs referencing the base embed, I think it reads nicer. But both function the same way.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After reading this: https://artsy.github.io/blog/2019/01/14/graphql-union-vs-interface/ I think I prefer Unions. |
||
| description 'All the different Embed types' | ||
|
|
||
| possible_types Types::Embed::WebsiteEmbed | ||
| end | ||
Uh oh!
There was an error while loading. Please reload this page.