Skip to content

Add {action}.graphql.data.* to actions#9787

Open
emmatown wants to merge 10 commits intomainfrom
data-on-actions
Open

Add {action}.graphql.data.* to actions#9787
emmatown wants to merge 10 commits intomainfrom
data-on-actions

Conversation

@emmatown
Copy link
Copy Markdown
Member

@emmatown emmatown commented Mar 11, 2026

This adds an experimental __data option on actions which defines what fields from the list the action should passed. true can be passed to receive all fields in which the types will use the list's update input or an object can be provided to specify specific fields and then those fields will be sent when the action is called from the Admin UI.

For example, it could be used in our usecase-versioning example to have an action that receives the version field:

actions: {
  publish: action({
    access: allowAll,
    ui: {
      label: 'Publish',
      itemView: { actionMode: { enabled: true } },
    },
    graphql: {
      __data: {
        version: true,
      },
    },
    resolve: async ({ where, data }, context) => {
      return context.sudo().db.Post.updateOne({
        where,
        data: {
          isPublished: true,
          version: data.version,
        },
      })
    },
  }),
},

The GraphQL for the example looks like this:

  publishPost(where: PostWhereUniqueInput!, data: PublishPostData!): Post
  publishPosts(data: [PublishPostArgs!]!): [Post]
}

input PublishPostData {
  version: Int!
}

input PublishPostArgs {
  where: PostWhereUniqueInput!
  data: PublishPostData!
}

Note this PR involves a change to the many action types and array of {ActionSingular}Args is passed instead of a {ListSingular}WhereUniqueInput which happens even if data isn't specified.

type Mutation {
  votePost(where: PostWhereUniqueInput!): Post
  votePosts(data: [VotePostArgs!]!): [Post]
}

input VotePostArgs {
  where: PostWhereUniqueInput!
}

Also, to support the types for this, actions must now also be declared with an action function like shown in the example.

Also, separately, we weren't actually evaluating the client side filters for actionMode, this fixes that.

No changeset since actions haven't been properly released.

@emmatown emmatown force-pushed the data-on-actions branch 9 times, most recently from 85e3a0e to 5df9f1f Compare March 12, 2026 06:26
}
}
actions {
key
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note because this wasn't requested previously, itemView.actionMode called with the actual item was never actually used

@emmatown emmatown force-pushed the data-on-actions branch 3 times, most recently from 11d11f1 to c62e0a5 Compare March 12, 2026 06:48
@emmatown emmatown marked this pull request as ready for review March 12, 2026 06:49
@emmatown emmatown requested a review from dcousens March 12, 2026 06:50
@emmatown emmatown changed the title Data on actions Data on actions and evaluate actionMode client side filters Mar 12, 2026
@emmatown emmatown force-pushed the data-on-actions branch 7 times, most recently from 6fd8507 to 387d73a Compare March 26, 2026 06:55
@emmatown emmatown changed the title Data on actions and evaluate actionMode client side filters Data on actions Mar 26, 2026
Comment thread packages/core/src/admin-ui/context.tsx Fixed
@emmatown emmatown force-pushed the operators-in-client-side-filters branch from ab8ed2c to 0c9aacd Compare March 27, 2026 00:41
Base automatically changed from operators-in-client-side-filters to fix-client-side-filters April 9, 2026 00:02
@emmatown emmatown force-pushed the fix-client-side-filters branch from 9751c9b to 3e4f684 Compare April 9, 2026 02:24
@emmatown emmatown changed the base branch from fix-client-side-filters to and-or-not-client-side-filters April 9, 2026 02:25
@dcousens dcousens force-pushed the and-or-not-client-side-filters branch from 066e789 to d110097 Compare April 9, 2026 06:39
@dcousens dcousens force-pushed the and-or-not-client-side-filters branch from d110097 to 41392e3 Compare April 9, 2026 06:42
Base automatically changed from and-or-not-client-side-filters to main April 9, 2026 23:46
@dcousens dcousens force-pushed the data-on-actions branch 4 times, most recently from 323da1d to f5a855d Compare April 10, 2026 00:45
@dcousens dcousens changed the title Data on actions Add {action}.graphql.data.* to actions Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants