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

(docs): split GraphQL image fragments APIs to their own pages #21536

Closed
wants to merge 3 commits into from
Closed

(docs): split GraphQL image fragments APIs to their own pages #21536

wants to merge 3 commits into from

Conversation

tesseralis
Copy link
Contributor

Description

Move graphql image fragment API documentation to their own pages, taking advantage of our API template to decrease build size by 10%.

Related Issues

Fixes: #21109

@tesseralis tesseralis requested review from a team as code owners February 17, 2020 20:40
const normalized = normalizeGatsbyApiCall(data.nodeAPIs.group)

const docs = data.jsdoc.nodes.reduce((acc, node) => {
const doc = node.childrenDocumentationJs
.filter(def => def.kind !== `typedef` && def.memberof)
.filter(
def => def.kind !== `typedef` && (includeTopLevel || def.memberof)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

adding includeTopLevel is a hack for now. Once we're approved that we want to do this, I can figure out a less hacky solution.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind expanding on that? I'm not too sure what the name suggests. And is the question about approval about adding that to the frontmatter or the general approach?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Originally, we're filtering the docs based on if def.memberof is defined -- i.e. only using docs that are part of some object, like actions.createPage.

Since the fragments are exported by themselves they'll be filtered out if we don't change this query in some way. My current solution is to add an option in the frontmatter to disable this check.

But I think the better solution would be to figure out why this query was needed (as in, what things we don't want to include in the doc) and come up with a better check that works for both that and the new fragments query.

Choose a reason for hiding this comment

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

To my knowledge, this change is good to go. But do we have any additional clarity on this? @LekoArts, do you know why the query is there or whether this might cause unforeseen issues?

Choose a reason for hiding this comment

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

As for the question about the meaning of includeTopLevel... seems like we should also put a note about that in the contributing docs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the Git history, I believe @gillkyle would know more about that query as it appears he wrote the file. It seems worth getting to the bottom of it rather than doing a workaround with contributing docs, in my opinion.

Copy link
Contributor

Choose a reason for hiding this comment

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

The idea of that query was to tie the updates to the fragments file in the core codebase to the docs so they wouldn't fall out of sync. This was a different use case than the other API reference pages so I see why there would need to be a bit of a change to the logic of the template.

As it stands now it's not doing much more than list all the exported fragments so if it would simplify things to just make that a list that we occasionally have to update from time to time I don't think that would be a problem either. Seems like maybe the added complexity of querying the list of fragments might not be worth whatever small benefit it adds 🤷‍♂

Choose a reason for hiding this comment

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

That's more or less where I'm at, Kyle. I'm struggling to think of a different way to do this that wouldn't create additional opportunities for docs to get out of sync. Also, my point about the contributing docs stands regardless of what we do if we go for something that requires setting an option somewhere, even if it's not exactly this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed in just making it a static list. There's precedence for it: many of our docs don't rely on pulling in JSDoc. In fact, we already have a list of the ImageSharp fragments in the Gatsby Image API, so an argument could be made that this content is repeated. I'm not sure what the best place would be to put information about the Contentful fragments though -- maybe in the gatsby-source-contentful readme and "sourcing from contentful", with a link to the Gatsby Image API for more details on the fragment options.

Choose a reason for hiding this comment

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

Solid points. I think your suggestions for where to add the information make sense and I'm comfortable with keeping the list of fragments.

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.

(docs) Consider moving/removing fragments section of GraphQL API
5 participants