Totara Talent Experience Platform Open Discussions

External API custom endpoints

 
Gabriel Baierle
External API custom endpoints
by Gabriel Baierle - Tuesday, 24 October 2023, 7:32 AM
 

Hi. I'm a developer and want to add new endpoints to get data from custom Totara plugins. I'd like to incorporate this endpoints to the new graphql External API queries, but I didn't find any docs on how to add new endpoints there.

Any suggestion and/or good practice on how to do it?

Craig Eves
Re: External API custom endpoints
by Craig Eves (Totara Support) - Tuesday, 24 October 2023, 4:15 PM
Group Totara

Hi Gabriel

Have you had a look at the Developers documentation on GraphQL this includes some examples that may be of help. If there are any gaps you want to ask questions on then you or your Partner can ask through creating a support ticket.

regards



Gabriel Baierle
Re: External API custom endpoints
by Gabriel Baierle - Saturday, 4 November 2023, 1:11 PM
 

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 \core\webapi\query_resolver {

public static function resolve(array $args, execution_context $ec) {

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 shauld I add new queries to the Totara External GraphQL API?