Totara GraphQL API Add New Query

Totara GraphQL API Add New Query


0

I’m trying to add a new query to the Totara External GraphQL API available on Totara v17.

Following the docs I’ve created the following structure:

  • local/plugin/webapi/external/get_completions.graphql
    query local_plugin_get_completions{
      local_plugin_get_completions{
        id
      }
    }
  • local/plugin/webapi/external/schema.graphqls
extend type Query {
    local_plugin_get_completions: [local_plugin_get_completions!]!
}

type local_plugin_get_completions{
    id: core_id,
}
  • local/plugin/classes/webapi/resolver/query
    class get_completions extends corewebapiquery_resolver {
        public static function resolve(array $args, execution_context $ec) {
            // Complete permission checks, then return the appropriate
            // raw data required by this query, which is then passed
            // to the type resolver for final processing.
            return [
                'id' => 'test'
            ];
        }
    }

When sending the request, I get a 200 response with empty data, no error in the server side. What am I missing here or how shaould I add new queries to the Totara External GraphQL API?


Load 5 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *