Skip to content
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

Field types should all implement a common interface for that type #153

Open
timkelty opened this issue Sep 11, 2018 · 5 comments
Open

Field types should all implement a common interface for that type #153

timkelty opened this issue Sep 11, 2018 · 5 comments

Comments

@timkelty
Copy link
Contributor

timkelty commented Sep 11, 2018

Example:

I have a Redactor field myText.

From that, I get GraphQL types, named by the field handle and field type, e.g. MyTextRedactorFieldData.

However, MyTextRedactorFieldData doesn't implement a common interface (RedactorFieldData?), which makes it hard when documenting usage for the API.

I'd love to be able to say "anything that implements RedactorFieldData, use in this way" …but currently I cannot.

This seems across the board with fields (not specific to redactor). Seems logical that CraftQL would do this automatically for every unique field type, rather than having every field type implement it.

@markhuot
Copy link
Owner

Hrm, that is peculiar. I don't even know that we need the interface. All Redactor fields should be able to implement the same field, regardless of the name of the field.

Note: I'm not seeing this for fields other than Redactor. What fields are you seeing unique per instance?

As for a fix I'll get this turned around and post back when it's done.

@timkelty
Copy link
Contributor Author

Hmmmm...

Examples:

These are perhaps different cases, but noting here:

  • Selection fields yieldMyFieldEnum (doesn't implement SelectOne or SelectMultiple, e.g.)
  • Matrices end up as MyFieldUnion, which is fine, but on that level or the Matrix block level there is no common interface (w/ id, enabled/status, e.g.).

That's all i've noticed so far.

@markhuot
Copy link
Owner

Ah, yea, this is a mistake the link field should probably use a single type instead of one per field. This could be a bad copy based from my old Redactor implementation. So,

  1. I need to update my Redactor implementation to not have multiple types per field
  2. It's probably worth opening a PR for the link field after I fix the Redactor field
  3. The selection fields and Matrices have to be different because they have different fields. I suppose I could make a common interface for them, but I'm not sure what advantages that has

@markhuot
Copy link
Owner

Okay, dev-master fixes point number one, above. I'll open a PR for the link field shortly to fix point number two. And then point number three, unfortunately can't change. If you see any alternatives for point three, please let me know.

This is on dev-master.

@timkelty
Copy link
Contributor Author

Thanks mark! nah, 3 isn't an issue, just wanted to point everything out. If it were to be addressed, I think a common interface would be the way to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants