-
Notifications
You must be signed in to change notification settings - Fork 291
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
Update post lib to use WP posts per page value #176
Conversation
src/data/posts.js
Outdated
@@ -235,3 +235,11 @@ export const QUERY_POST_SEO_BY_SLUG = gql` | |||
} | |||
} | |||
`; | |||
|
|||
export const QUERY_POST_PER_PAGE = gql` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just out of curiosity, do you think this is better suited as its own individual query?
wouldn't we have it available throughout the application to easily use if we added it to the site
query?
export const QUERY_SITE_DATA = gql` |
thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah thats a really good idea! totally missed. I will make the changes, thanks @colbyfayock !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a problem with this approach: If we store this value withing the site context, we can't have access to it inside fetching functions (getStaticProps) to pre-render as is required to generate the pagination ... Do you know if there is a way to retrieve this context data inside getStaticProps? Maybe in this case its worth having like its now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so interestingly, i was using NextAuth which passes looks at the context
available as an arugment on getServerSideProps
, i wonder if it's available on there by change?
https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
i'm not sure how NextAuth is doing it though so might be a long shot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they work with cookies: when using getServerSideProps is possible to extract from that context object the http request and check the cookie with the info. In the case of getStaticProps is not possible.... trying to figure out if there is another way to do it ..
can you merge in the latest into here? then ill see if i can poke around a little bit |
@colbyfayock let me see if I can push it, I had some WIP and now the branch is looking little different 😅 (is a mess with testing lines xD). EDIT: Done! |
76e4f01
to
85a3d12
Compare
After researching what the approach might be, I haven't come up with any clear answers 😞. Here are some findings/tries I made (in case are useful):
Other approachs that could work, but maybe not suitable solution:
What do you think the approach should be? Thoughs on other alternatives? |
hm yeah, i poked around a bit and i see what you mean as far as the current solution you're proposing, do you think we even need to memoize? wouldn't the query get cached? |
i love the idea of a config, maybe we can play around with that idea separately the only concern is dealing with issues like the wp search index where it was causing build issues on first run |
About config it would be nice, because it also can work for #173 and other WP variables at one place. Hopefully using the node path module for the read there should be no problems, but that's something we can only know by testing in that environment... About the current solution, you have a great point: memoize is not required as Apollo is already doing that work. Should I fix that part and leave this solution for now? |
yeah i think that sounds good, works for me. and if you want to merge in the latest again, got a conflict it |
85a3d12
to
e391cc5
Compare
Oops not sure what happened ... just made the changes, and force pushed to the branch but it closed 😶 ... I will reopen on another PR with the last changes. |
I was playing with git reset while testing and probably pushed with no changes by error 😓 . Luckily I had the changes locally, I'm opening another PR with the same solution |
Description
It updates the variable post per page querying
readingSettingsPostsPerPage
. If the previous POST_PER_PAGE variable is set, it will use it displaying a warn:It is used a functionality similar to apollo client, memoizing the value in order to avoid extra requests (since it is used in various spots)
Fixes #171