distraction
-
sign up from blog template
Contentful’s Getting started with GraphQL
-
exploring endpoints
-
query can have multiple queries, as long as unique lables/alias
-
Contentful has collection filters out-of-box (probably their resolvers)
-
-
fetching w/ React usestate, useeffect, apollo
-
re-watch and build 1-off react app
-
(deferred) suggestion
npm audit fix --force
-
(deferred) understand
npm start
vsyarn start
-
AJAX/
window.fetch()
: GET (read) vs POST (write but can also read) -
useState - add a state variable
let [currentVal, setterFn] = useState(initVal)
-
useEffect - synchronize w/ external system (call once per component mount instead of every mutation)
-
-
refactor React app using env variables
-
in $PROJ_ROOT/.env properties file,
REACT_APP_*
exposed toprocess.env
to keep secrets out of source (assuming gitignore excludes .env files) -
moving access_token from query-parameter to request header
-
-
refactor app with custom hook in react
-
refactor app for error handling (auth, validation)
-
refactor app with React Proptypes, tailwindCSS; add fields to content model
-
refactor app to include image
-
refactor app w/ rich-text
-
markdown URLs are hard-coded ⇒ hard to maintain/brittle
-
field has json, links
-
contentful provides rich-text-react-renderer, rich-text-types to simplify json⇒HTML
documentToReactComponents(bio.json)
-
but still a lot of work to convert every HTML element
-
-
npm install --save @contentful/rich-text-types @contentful/rich-text-react-renderer
-
contentful references (multi ref to string)
-
GraphQL fragments & query complexity - start by using limits on collections
-
fragments '…${fragName}' (re-use)
-
collections filter/linkedfrom
-
query complexity ⇐ use limit to reduce query cost; errors will share the cost/threshold if too high
-
-
preview / query variables
-
complexity of targeting preview docs (CPA token vs CDA token)
-
variables can be optional/mandatory/have defaults
-
-
server directives: conditional queries
-
additional references
-
https://www.contentful.com/developers/docs/references/graphql/ Contentful’s GraphQL API & extensions
-
https://graphql.org/learn/ general GraphQL
-
https://legacy.reactjs.org/docs/getting-started.htmlhttps://react.dev/learn to learn more ReactJS
-
-
sign up from blog template