-
Notifications
You must be signed in to change notification settings - Fork 5.6k
new slab components #19354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sergio-eliot-rodriguez
merged 9 commits into
PipedreamHQ:master
from
sergio-eliot-rodriguez:slab-components
Dec 5, 2025
Merged
new slab components #19354
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5e9e754
new slab components
a1af816
Merge branch 'PipedreamHQ:master' into slab-components
sergio-eliot-rodriguez 0187491
Merge branch 'PipedreamHQ:master' into slab-components
sergio-eliot-rodriguez ec1bc97
updated pnpm-lock
edda732
fixing lints
3e84577
Merge branch 'PipedreamHQ:master' into slab-components
sergio-eliot-rodriguez dc68933
moved graphql queries to /common folder
e98b5ec
addded common folder
d98345c
Merge branch 'master' into slab-components
sergio-eliot-rodriguez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import slab from "../../slab.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "slab-get-posts", | ||
| name: "Get Posts", | ||
| description: "Get posts by ID. See [documentation](https://studio.apollographql.com/public/Slab/variant/current/home), [schema link](https://studio.apollographql.com/public/Slab/variant/current/explorer?searchQuery=RootQueryType.posts)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| props: { | ||
| slab, | ||
| postIds: { | ||
| type: "string[]", | ||
| label: "Post IDs", | ||
| description: "Select one or more posts to retrieve", | ||
| options: async function({ prevContext }) { | ||
| return this.slab.listPostsForOptions({ | ||
| cursor: prevContext?.cursor, | ||
| }); | ||
| }, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const query = ` | ||
| query GetPosts($ids: [ID!]!) { | ||
| posts(ids: $ids) { | ||
| id | ||
| title | ||
| linkAccess | ||
| archivedAt | ||
| publishedAt | ||
| insertedAt | ||
| updatedAt | ||
| version | ||
| content | ||
| banner { | ||
| original | ||
| thumb | ||
| preset | ||
| } | ||
| owner { | ||
| id | ||
| name | ||
| } | ||
| topics { | ||
| id | ||
| name | ||
| } | ||
| } | ||
| } | ||
| `; | ||
| const variables = { | ||
| ids: this.postIds, | ||
| }; | ||
| const response = await this.slab._makeRequest({ | ||
| $, | ||
| data: { | ||
| query, | ||
| variables, | ||
| }, | ||
| }); | ||
| const posts = response.posts || []; | ||
| $.export("$summary", `Successfully retrieved ${posts.length} post(s)`); | ||
| return posts; | ||
| }, | ||
| }; | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import slab from "../../slab.app.mjs"; | ||
| import { LIST_POSTS_QUERY } from "../../common/queries.mjs"; | ||
|
|
||
| export default { | ||
| key: "slab-list-posts", | ||
| name: "List Posts", | ||
| description: "List posts in the organization. See [documentation](https://studio.apollographql.com/public/Slab/variant/current/home), [schema link](https://studio.apollographql.com/public/Slab/variant/current/explorer?searchQuery=RootQueryType.search)", | ||
| version: "0.0.1", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| slab, | ||
| first: { | ||
| propDefinition: [ | ||
| slab, | ||
| "first", | ||
| ], | ||
| }, | ||
| after: { | ||
| propDefinition: [ | ||
| slab, | ||
| "after", | ||
| ], | ||
| }, | ||
| last: { | ||
| propDefinition: [ | ||
| slab, | ||
| "last", | ||
| ], | ||
| }, | ||
| before: { | ||
| propDefinition: [ | ||
| slab, | ||
| "before", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const query = LIST_POSTS_QUERY; | ||
| const variables = { | ||
| query: "", | ||
| ...(this.first && { | ||
| first: parseInt(this.first), | ||
| }), | ||
| ...(this.after && { | ||
| after: this.after, | ||
| }), | ||
| ...(this.last && { | ||
| last: parseInt(this.last), | ||
| }), | ||
| ...(this.before && { | ||
| before: this.before, | ||
| }), | ||
| }; | ||
| const response = await this.slab._makeRequest({ | ||
| $, | ||
| data: { | ||
| query, | ||
| variables, | ||
| }, | ||
| }); | ||
| const edges = response.search?.edges || []; | ||
| const posts = edges | ||
| .map((edge) => edge.node?.post) | ||
| .filter(Boolean); | ||
| const pageInfo = response.search?.pageInfo || {}; | ||
| $.export("$summary", `Successfully retrieved ${posts.length} post(s)`); | ||
| return { | ||
| posts, | ||
| pageInfo, | ||
| edges, | ||
| }; | ||
| }, | ||
| }; | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| import slab from "../../slab.app.mjs"; | ||
| import { SEARCH_POSTS_QUERY } from "../../common/queries.mjs"; | ||
|
|
||
| export default { | ||
| key: "slab-search-posts", | ||
| name: "Search Posts", | ||
| description: "Search for posts based on query. See [documentation](https://studio.apollographql.com/public/Slab/variant/current/home), [schema link](https://studio.apollographql.com/public/Slab/variant/current/explorer?searchQuery=RootQueryType.search)", | ||
| version: "0.0.1", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| slab, | ||
| query: { | ||
| type: "string", | ||
| label: "Query", | ||
| description: "Search query string", | ||
| }, | ||
| first: { | ||
| propDefinition: [ | ||
| slab, | ||
| "first", | ||
| ], | ||
| }, | ||
| after: { | ||
| propDefinition: [ | ||
| slab, | ||
| "after", | ||
| ], | ||
| }, | ||
| last: { | ||
| propDefinition: [ | ||
| slab, | ||
| "last", | ||
| ], | ||
| }, | ||
| before: { | ||
| propDefinition: [ | ||
| slab, | ||
| "before", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const query = SEARCH_POSTS_QUERY; | ||
| const variables = { | ||
| query: this.query, | ||
| ...(this.first && { | ||
| first: parseInt(this.first), | ||
| }), | ||
| ...(this.after && { | ||
| after: this.after, | ||
| }), | ||
| ...(this.last && { | ||
| last: parseInt(this.last), | ||
| }), | ||
| ...(this.before && { | ||
| before: this.before, | ||
| }), | ||
| }; | ||
| const response = await this.slab._makeRequest({ | ||
| $, | ||
| data: { | ||
| query, | ||
| variables, | ||
| }, | ||
| }); | ||
| const edges = response.search?.edges || []; | ||
| const posts = edges | ||
| .map((edge) => edge.node?.post) | ||
| .filter(Boolean); | ||
| const pageInfo = response.search?.pageInfo || {}; | ||
| $.export("$summary", `Successfully found ${posts.length} post(s) matching "${this.query}"`); | ||
| return { | ||
| posts, | ||
| pageInfo, | ||
| edges, | ||
| }; | ||
| }, | ||
| }; | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| export const SEARCH_POSTS_QUERY = ` | ||
| query SearchPosts($query: String!, $first: Int, $after: String, $last: Int, $before: String) { | ||
| search(query: $query, types: [POST], first: $first, after: $after, last: $last, before: $before) { | ||
| edges { | ||
| node { | ||
| ... on PostSearchResult { | ||
| title | ||
| highlight | ||
| content | ||
| post { | ||
| id | ||
| title | ||
| linkAccess | ||
| archivedAt | ||
| publishedAt | ||
| insertedAt | ||
| updatedAt | ||
| version | ||
| content | ||
| banner { | ||
| original | ||
| thumb | ||
| preset | ||
| } | ||
| owner { | ||
| id | ||
| name | ||
| } | ||
| topics { | ||
| id | ||
| name | ||
| } | ||
| } | ||
| } | ||
| } | ||
| cursor | ||
| } | ||
| pageInfo { | ||
| hasNextPage | ||
| hasPreviousPage | ||
| startCursor | ||
| endCursor | ||
| } | ||
| } | ||
| } | ||
| `; | ||
|
|
||
| export const LIST_POSTS_QUERY = ` | ||
| query ListPosts($query: String!, $first: Int, $after: String, $last: Int, $before: String) { | ||
| search(query: $query, types: [POST], first: $first, after: $after, last: $last, before: $before) { | ||
| edges { | ||
| node { | ||
| ... on PostSearchResult { | ||
| title | ||
| highlight | ||
| content | ||
| post { | ||
| id | ||
| title | ||
| linkAccess | ||
| archivedAt | ||
| publishedAt | ||
| insertedAt | ||
| updatedAt | ||
| version | ||
| content | ||
| banner { | ||
| original | ||
| thumb | ||
| preset | ||
| } | ||
| owner { | ||
| id | ||
| name | ||
| } | ||
| topics { | ||
| id | ||
| name | ||
| } | ||
| } | ||
| } | ||
| } | ||
| cursor | ||
| } | ||
| pageInfo { | ||
| hasNextPage | ||
| hasPreviousPage | ||
| startCursor | ||
| endCursor | ||
| } | ||
| } | ||
| } | ||
| `; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Eliminate query duplication using GraphQL fragments.
SEARCH_POSTS_QUERYandLIST_POSTS_QUERYare nearly identical—same variables, endpoint, and response fields. Maintaining two separate queries violates the DRY principle and creates a maintenance burden if the schema changes.Extract the repeated post fields and pagination structure into a GraphQL fragment, then reuse it in both queries:
Alternatively, if the queries are truly interchangeable, consolidate them into a single exported query and use it in both actions.
🤖 Prompt for AI Agents