This FREE plugin from @andrenosouza allows you to interact with data from the WP-Polls plugin via GraphQL Queries and Mutations
Community PluginView Plugin on Github
You can install and activate the plugin like any WordPress plugin. Download the .zip from Github and add to your plugins directory, then activate.
It requires you to have WP-Polls plugin first in order to work. You can get it here.
This plugin adds a new
vote mutation to the WPGraphQL Schema.
This can be used like so:
- The integer
idis unique identifier for the poll you are voting.
- The integer
userIdis the identifier of the voter.
- The string
idsof the user selected answers. Note: they have to be comma separated only.
It returns a status code and a respective message after the operation has been executed or not.
You can query polls by doing the following query:
id: (integer) is the unique identifier for the poll you are voting.
question: (string) is a text describing the poll.
totalVotes: (integer) is the total amount of votes in this poll.
open: (boolean) is the current status of the poll. Telling either if it's available for voting or not.
maxAnswers: (integer) is the number of answers that can be selected per user before voting.
voted: (boolean) tells if the user has already voted in this poll.
answers: (array) is an array of object containing detailed information about the poll's options.
id: (integer) is the unique identifier for the respective answer.
description: (string) is a text representing an option for voting.
votes: (integer) is the unique identifier for the poll you are voting.
If you need to query an specific poll you can do it by passing the poll
id through the query, like the example bellow:
The statuses returned by the vote mutation are normal HTTP codes. The ones used in this plugin are:
400: Bad Request
500: Internal Server Error