Code Monkey home page Code Monkey logo

contentful-graphql-react-tutorial's Introduction

README

distraction

Tutorial series

  1. exploring endpoints

    • query can have multiple queries, as long as unique lables/alias

    • Contentful has collection filters out-of-box (probably their resolvers)

  2. fetching w/ React usestate, useeffect, apollo

    • re-watch and build 1-off react app

    • (deferred) suggestion npm audit fix --force

    • (deferred) understand npm start vs yarn 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)

  3. refactor React app using env variables

    • in $PROJ_ROOT/.env properties file, REACT_APP_* exposed to process.env to keep secrets out of source (assuming gitignore excludes .env files)

    • moving access_token from query-parameter to request header

  4. refactor app with custom hook in react

  5. refactor app for error handling (auth, validation)

  6. refactor app with React Proptypes, tailwindCSS; add fields to content model

  7. refactor app to include image

  8. 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

  9. npm install --save @contentful/rich-text-types @contentful/rich-text-react-renderer

  10. contentful references (multi ref to string)

  11. 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

  12. preview / query variables

    • complexity of targeting preview docs (CPA token vs CDA token)

    • variables can be optional/mandatory/have defaults

  13. server directives: conditional queries

  14. additional references

Meta Notes

  • react APIs: use relay or Apollo to manage/centralize many queries/calls

  • Contentful field refactoring (to delete) in content model: disable, save, delete, save

  • Contentful provides transformation options/filters in GraphQL queries for assets

other

  1. Learn GraphQL

  2. sign up from blog template

contentful-graphql-react-tutorial's People

Contributors

itgumby avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.