watermarkchurch / wcc-contentful

An alternative to Contentful's contentful.rb ruby client, contentful_model, and contentful_rails gems all in one.
MIT License
2 stars 1 forks source link

unknown field type RichText for field body (ArgumentError) #260

Closed imanpalsingh closed 1 year ago

imanpalsingh commented 2 years ago

Rails : 5.2.0 Ruby: 2.7.5

Config

WCC::Contentful.configure do |config|
  config.access_token = token
  config.space = space
end

WCC::Contentful.init!

On running rails server rails s I get this error

.rvm/gems/ruby-2.7.5/gems/wcc-contentful-1.1.2/lib/wcc/contentful/content_type_indexer.rb:153:in `find_field_type': unknown field type RichText for field body (ArgumentError)

I have a content model named Page which has a field named body of type Rich Text

gburgett commented 2 years ago

Hi @imanpalsingh ! We currently do not support RichText fields. We'd be interested in having a design discussion with you to figure out how best to do that! Would you be interested in contributing?

imanpalsingh commented 2 years ago

Hi @gburgett ! I'm not a ruby expert but I would love to contribute.

gburgett commented 2 years ago

Great! I would love to work on this with you. There's a couple things we should do to get started:

  1. Can you download a sample of the Content Type in your space that contains the rich text field? We'll need a JSON file containing the Content Type definition and Editor Interface. The easiest thing to do would be to just attach your contentful-schema.json to this issue.

  2. Can you also download a JSON file of an Entry in your contentful space that has a Rich Text field in it? The easiest thing to do would be to use curl to query the Contentful Content Delivery API and write the output to a JSON file. We should use the "include" parameter as well, to make sure we are getting the entries that are referenced by your rich text field.

Something like this:

curl -H "Authorization: Bearer $CONTENTFUL_ACCESS_TOKEN" https://cdn.contentful.com/spaces/$CONTENTFUL_SPACE_ID/entries?sys.id=$ENTRY_ID&include=1 > entry_with_rich_text.json

Those JSON files will form the basis of a test fixture so that we can write a unit test for supporting Rich Text in general.

gburgett commented 2 years ago

I'm copying these here for reference: https://www.contentful.com/developers/docs/concepts/rich-text/

https://github.com/contentful/contentful.rb/blob/master/lib/contentful/coercions.rb

So it looks like the Contentful ruby gem just returns a hash for a Rich Text field. But they automatically resolve links. Interesting.

We should probably do the same thing to start with, and later on we can add some better functionality.

imanpalsingh commented 2 years ago

Hi @gburgett , sorry for the delay, been busy at work.

  1. Did you mean this json?
  2. Here it is.

Thanks for the references, going through them now.

gburgett commented 2 years ago

Looks great! I've got some stuff that I've already been working on, I'll push it up as a PR in a minute. We can then talk about how to proceed from there.

gburgett commented 1 year ago

Fixed in v1.2.0