Jump to content

GraphQL for ProcessWire


dadish

Recommended Posts

  • 2 weeks later...

Hello !

Thank you for this very nice module @dadish

I'm trying to get the ProField RepeaterMatrix to work based on this fork here by Tulios link.

But I'm having a hard time, struggling for some days deciphering the complex GraphQL architecture and logging everything in the console haha

I really would like to use it like this screenshot below, with fragments for every repeater matrix types.

 

image.png.1d5f91e5f5971e25745556bc1f10268a.png

 

The main issue I have is I can't find a way to build the list of every possible templates types.

The way RepeaterMatrix works is it is differentiating the types based on the repeater_matrix_type. It doesn't seem to work with templates. I tried to use the constructor `new Template()` to create some based on this property but I don't know where to add this line.

Also should I create a new RepeaterMatrixPageArrayType based on your PageArrayType?

Any chance you would take a look? I know it's a ProField, but if you got some time I would be very grateful

  • Like 1
Link to comment
Share on other sites

Hello @Matoseb,

I haven't used any of the pro fields, myself. So I don't know much about them. But conceptually they should be very similar to list of pages.

4 hours ago, Matoseb said:

The way RepeaterMatrix works is it is differentiating the types based on the repeater_matrix_type. It doesn't seem to work with templates. I tried to use the constructor `new Template()` to create some based on this property but I don't know where to add this line.

You should take a closer look what I do in PageType. I create the fields of the page by inspecting it's template. I don't know what kind of API the repeater_matrix_type has, but I suspect similar. But even then, I have a separate type generator for each supported field. If RepeaterMatrix does not use those as underlying FieldType classes, then you'll have to recreate for each of them on your own.

5 hours ago, Matoseb said:

Also should I create a new RepeaterMatrixPageArrayType based on your PageArrayType?

Yes, but the bulk of the work would be implementing the equivalent of PageType that would be responsible for creating types for each repeater_matrix_type. The PageArrayType simply wraps the PageType into an array and adds things like pagination, first item, last item, total count, etc.

5 hours ago, Matoseb said:

Any chance you would take a look? I know it's a ProField, but if you got some time I would be very grateful

Sorry bud. The ProFields are out of the scope of this plugin.

Link to comment
Share on other sites

On 1/2/2022 at 12:55 AM, ngrmm said:

UPDATE: seems it has something to do with my site-settings
I tried it in JS and it works

Glad to see you progressed on this.

On 1/2/2022 at 12:55 AM, ngrmm said:

However when I use /graphql/ as URL i see an object in the console. When I use /processwire/setup/graphql/ I see a json in the console

The /processwire/setup/graphql/ is for internal/admin use only. You should focus on the /graphql/ endpoint.

Link to comment
Share on other sites

Thank you dadish for you infos, that was fast

I'll try again soon!

1 hour ago, dadish said:

I haven't used any of the pro fields, myself. So I don't know much about them. But conceptually they should be very similar to list of pages.

Yes, they are based on the Repeaters. It contains a list of pages of the same template, but with repeater_matrix_type  differentiating the different possible entries.

1 hour ago, dadish said:

I don't know what kind of API the repeater_matrix_type has, but I suspect similar.

The repeater_matrix_type field is a FieldtypeInteger

Link to comment
Share on other sites

Good news !

I managed to add some good support for ProField RepeaterMatrix.

Github link (experimental, use at your own risk!)

Todo

  • Only allow possible fields per matrix types in the schema.
  • Add matrix type as names and not as integers. Easier to read.
  • Support for mutations / inputfields.
  • Repeater Depth/Indents -> Need to add feature to FieldTypeRepeater.

However I can't share it as a third party module. You have to insert the php file manually.

This is due to the static method field() {} not being called from a third party module. Feature request? 😄

BTW @dadish I couldn't find a way to add invisible types to the Schema during construction. I tried to use the modifySchema hook, but no luck. Could be useful

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...