ample / gatsby-starter-ample

This starter serves as the starting point for Ample’s Gatsby projects.
https://gatsby-starter-ample.netlify.app
MIT License
2 stars 1 forks source link

SeoMeta fields don't have a predictable type #119

Closed seancdavis closed 4 years ago

seancdavis commented 4 years ago

I have a project in which I have multiple models. Let's say they are:

I also have a twitter object on the seo object from which the node is created.

The Event model is processed first, and that makes the type of the twitter field EventSeoTwitter. That's okay that it's inferred (theoretically), but Gatsby then infers all twitter fields as EventSeoTwitter, regardless of which model they are attached to.

Functionally that's okay, but it feels odd.

seancdavis commented 4 years ago

This can be fixed by specifying the type name and explicitly defining the schema shape for SeoMeta objects.

type SeoMetaOg @infer {
  description: String
  image: File @fileByRelativePath
  title: String
}

type SeoMetaTwitter @infer {
  card: String
  description: String
  image: File @fileByRelativePath
  title: String
}

type SeoMeta @infer {
  description: String
  image: File @fileByRelativePath
  og: SeoMetaOg
  title: String
  twitter: SeoMetaTwitter
}

I'm going to keep this open because I think it would be worthwhile to add this into the starter. Adjusting the tags for the issue, though.

And it should come after #90 is implemented.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

seancdavis commented 4 years ago

This has been solved by explicitly defining types and our schema plugin.