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

Unmarshal Media interface #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

vinhluan
Copy link
Contributor

Since gqlgen generates Go interfaces for GraphQL interfaces, leading to an error when unmarshalling JSON data contains interface types. This pull request introduces custom UnmarshalJSON methods to unmarshal Media interface.

Related issue: 99designs/gqlgen#2446

Example query with this issue:

query products {
	products(first: 10) {
		id
		title
		handle
		media {
			edges {
				node {
					mediaContentType
					...on MediaImage {
						id
						alt
						mimeType
						image {
							height
							src
							width
						}
					}
					...on Model3d {
						id
						alt
						originalSource {
							url
							format
							filesize
							mimeType
						}
						preview {
							image {
								src
							}
						}
					}
					...on Video {
						id
						alt
						duration
						originalSource {
							url
							format
							mimeType
 							height
							width
						}
						preview {
							image {
								src
							}
						}
					}
					...on ExternalVideo {
						id
						originUrl
						embedUrl
						preview {
							image {
								src
							}
						}
					}
				}
			}
		}
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant