Skip to content

Data on actions#9787

Open
emmatown wants to merge 2 commits intooperators-in-client-side-filtersfrom
data-on-actions
Open

Data on actions#9787
emmatown wants to merge 2 commits intooperators-in-client-side-filtersfrom
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
@emmatown emmatown force-pushed the data-on-actions branch 3 times, most recently from 990f8e2 to 0a35621 Compare March 26, 2026 23:36
@emmatown emmatown changed the base branch from main to fix-client-side-filters March 26, 2026 23:43
@emmatown emmatown force-pushed the fix-client-side-filters branch from 9e77b11 to 3e4f684 Compare March 26, 2026 23:47
@emmatown emmatown changed the base branch from fix-client-side-filters to operators-in-client-side-filters March 27, 2026 00:20
@emmatown emmatown force-pushed the data-on-actions branch 2 times, most recently from 73537a7 to 955eca0 Compare March 27, 2026 00:41
@emmatown emmatown force-pushed the operators-in-client-side-filters branch from ab8ed2c to 0c9aacd Compare March 27, 2026 00:41
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.

1 participant