Hi!
I am trying to build a plugin for Talk, and I would like some settings to be set up in the admin. The talk-recipes and this repo don't have most of the options of plugins documented. But doing some reverse engineering and checking the old docs, I was able to use a Slot.
Stay with me, as I try to describe my issue. I have the following in my component:
<ConfigureCard
checked={settings.myPluginEnable}
onCheckbox={this.updateMyPluginEnable}
title={t('configure.my_plugin_enable')}
>
Translations are good (thank Bel for the recipe!) but the checkbox never appears. After some digging, I guessed it's because settings.myPluginEnable is never defined (not true, not false, undefined)
Next step, I check two things: the other "native" stream options and the avatar recipe, which is augmenting the User with an avatar field.
This is my plugin container then:
import {gql} from 'react-apollo';
import {withFragments} from 'plugin-api/beta/client/hocs';
import MyPlugin from '../components/MyPlugin';
export default withFragments({
settings: gql`
fragment MyPlugin_settings on Settings {
myPluginEnable
}
`
})(MustRead);
But the admin panel showed an error: GraphQL error: Cannot query field "myPluginEnable" on type "Settings". Did you mean "questionBoxEnable"?
I then guessed, I had to let the system know the Settings model has to be updated with this new property, so I added to my plugin/index.js:
typeDefs: `
type Setting {
myPluginEnable: Boolean
}
`,
resolvers: {
Setting: {
myPluginEnable(setting) {
if (setting && typeof setting.myPluginEnable !== 'undefined') return setting.myPluginEnabled;
return false; // default value?
}
}
},
It didn't work. It seems like I'm missing something that needs to be setup on my plugin/client/index.js with the fragments and/or mutations keys, but even reading the example https://github.com/coralproject/talk-recipes/blob/master/plugins/avatar/client/index.js I am unsure what everything means here.
Would love help figuring this out, and would love to update the docs myself on plugin development with whatever you teach me :-)
Best,
It's a known issue the lack of documentation around the plugin system. We will updated soon on how to fix what you're working on :)
@wyattjoh I would love to help, how can I?
Hey @tomasdev, wanna take a look at some of our new docs? We would love if you could let us know what's missing!
Currently in an open PR, you can view the Plugin/Server API docs here: https://github.com/coralproject/talk/blob/627170a970bd3c5f2bc0c9a91a66d3b4248226ad/docs/source/reference/server.md
PR is here: https://github.com/coralproject/talk/pull/1399
@kgardnr you are AWESOME pal!
This is extremely useful, seriously good work. It really did help me and I've added some questions to the open PR (inside the server.md file) and would add anything else that occurs to me. Let me know if that's not the best place to suggest.
Update: also noticed there's no client.js counterpart for the new docs... (slots, mutations, fragments are all key pieces when developing plugins)
Most helpful comment
It's a known issue the lack of documentation around the plugin system. We will updated soon on how to fix what you're working on :)