Skip to content

Instantly share code, notes, and snippets.

@jasonbahl
Created October 25, 2021 21:39
Show Gist options
  • Save jasonbahl/c619fc9e3f128940178eb4c51697bc3c to your computer and use it in GitHub Desktop.
Save jasonbahl/c619fc9e3f128940178eb4c51697bc3c to your computer and use it in GitHub Desktop.
/**
* This is an example showing how to add a custom action
* to the operation action menu
*/
hooks.addFilter(
"graphiql_operation_action_menu_items",
"graphiql-extension",
(menuItems, props) => {
const { Menu } = props;
console.log({
graphiql_operation_action_menu_items: {
menuItems,
props,
},
});
// Return the menuItems, with our new item added
return {
...menuItems,
test: (
<Menu.Item
onClick={({ domEvent }) => {
domEvent.preventDefault();
domEvent.stopPropagation();
alert(`clicked the new menu item!`);
console.log({
filteredOperationActionMenuItem: {
menuItems,
props,
},
});
}}
>
Filtered Item!
</Menu.Item>
),
};
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment