Home / Function/ create() — supabase Function Reference

create() — supabase Function Reference

Architecture documentation for the create() function in connections.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  9eb51941_1b09_8b41_0cad_11f562d6a0ba["create()"]
  b3c9d93a_b9b6_3cfd_c58c_63d2b6a0e312["resolveSearch()"]
  b3c9d93a_b9b6_3cfd_c58c_63d2b6a0e312 -->|calls| 9eb51941_1b09_8b41_0cad_11f562d6a0ba
  2373fead_7dbc_efa1_871c_2e08f6c27649["ok()"]
  9eb51941_1b09_8b41_0cad_11f562d6a0ba -->|calls| 2373fead_7dbc_efa1_871c_2e08f6c27649
  1f4b3f46_f760_9ee2_a55d_c30feb0bb3fd["paginateArray()"]
  9eb51941_1b09_8b41_0cad_11f562d6a0ba -->|calls| 1f4b3f46_f760_9ee2_a55d_c30feb0bb3fd
  1ee162b1_d232_4846_ef61_0018a3d5f851["error()"]
  9eb51941_1b09_8b41_0cad_11f562d6a0ba -->|calls| 1ee162b1_d232_4846_ef61_0018a3d5f851
  040a5796_eb59_9ff7_60d0_b127fcaa25c2["map()"]
  9eb51941_1b09_8b41_0cad_11f562d6a0ba -->|calls| 040a5796_eb59_9ff7_60d0_b127fcaa25c2
  style 9eb51941_1b09_8b41_0cad_11f562d6a0ba fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/resources/utils/connections.ts lines 279–311

  static async create<ItemType, FetchArgs = unknown, ErrorType = Error>(
    options: CollectionBuildArgs<ItemType, FetchArgs, ErrorType>
  ): Promise<Result<GraphQLCollection<ItemType>, GraphQLError | ErrorType>> {
    const { fetch, args = {}, getCursor, items } = options

    if (items) {
      return Result.ok(GraphQLCollectionBuilder.paginateArray({ items, args }))
    }

    if (args.first && args.last) {
      return Result.error(new GraphQLError('Cannot specify both first and last arguments'))
    }

    return (await fetch(args)).map(
      ({ items: fetchedItems, totalCount, hasNextPage = false, hasPreviousPage = false }) => {
        const edges = fetchedItems.map((item) => {
          return { node: item, cursor: getCursor(item) }
        })

        return {
          edges,
          nodes: fetchedItems,
          totalCount,
          pageInfo: {
            hasNextPage,
            hasPreviousPage,
            startCursor: edges.length > 0 ? edges[0].cursor : null,
            endCursor: edges.length > 0 ? edges[edges.length - 1].cursor : null,
          },
        }
      }
    )
  }

Subdomains

Called By

Frequently Asked Questions

What does create() do?
create() is a function in the supabase codebase.
What does create() call?
create() calls 4 function(s): error, map, ok, paginateArray.
What calls create()?
create() is called by 1 function(s): resolveSearch.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free