Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add CraftQL support for text and html fields. #20

Merged
merged 1 commit into from
Nov 23, 2018
Merged

Add CraftQL support for text and html fields. #20

merged 1 commit into from
Nov 23, 2018

Conversation

mattstein
Copy link
Contributor

@mattstein mattstein commented Nov 13, 2018

Hi Selvin! I'm playing with CraftQL and just Doxter to play nice. Previously, using the field handle in a GraphQL query would have resulted in an error:

Query:

{
    entries {
        ... on Blog {
            doxterFieldHandle
        }
    }
}

Result:

String cannot represent non scalar value: instance of selvinortiz\doxter\fields\data\DoxterData

This PR requires a sub-selection of either text or html. Query:

{
    entries {
        ... on Blog {
            doxterFieldHandle {
                text
                html
            }
        }
    }
}

More thrilling result:

{
    "data": {
        "entries": [
        {
            "text": "GraphQL is the bee's knees, and it's just *begging* to get Markdown from Doxter.",
            "html": "<p>GraphQL is the bee&#8217;s knees, and it&#8217;s just <em>begging</em> to get Markdown from Doxter.</p>"
        }
    ]
}

@selvinortiz
Copy link
Contributor

@mattstein I'm sorry for the delay in getting back to you, Matt. Thank you for taking the time to add this in Doxter. I'll merge and cut a new release.

@selvinortiz selvinortiz merged commit b8ab37a into verbb:master Nov 23, 2018
@selvinortiz
Copy link
Contributor

@mattstein Did you test with and without CraftQL installed? Just wondering if checking whether the class exists is the safest way to register the event listener. Wondering if it would make more sense to check whether or not the plugin is installed?

@mattstein
Copy link
Contributor Author

You're welcome, and no worries on timing @selvinortiz!

I just did a quick local test removing CraftQL via composer and restarting the development server. I can confirm that Doxter behaves normally in the control panel (entry detail w/Matrix block + Doxter plugin settings) and via front-end templates. The same is true when CraftQL is required with composer but not yet installed, as well as installed but disabled.

If there's anything else I should poke at, kindly let me know!

I'm honestly not sure if it makes more sense to see if the plugin's installed; I followed the lead of https://github.com/ethercreative/simplemap/blob/v3/src/SimpleMap.php but assume either way would be safe now that I've tested ;)

@selvinortiz
Copy link
Contributor

@mattstein That sounds good to me. I'll cut a new release.

Thank you, Matt.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants