Skip to content
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

Fragment #37

Open
IzumiSy opened this issue Oct 17, 2024 · 0 comments
Open

Fragment #37

IzumiSy opened this issue Oct 17, 2024 · 0 comments
Assignees
Labels
feature New feature or request
Milestone

Comments

@IzumiSy
Copy link
Member

IzumiSy commented Oct 17, 2024

Fabrix can support fragment for directive configuration reusability.

The configuration given to fragments with fabrix directives are inherited into the query, so configurations can be reusable through fragments.

fragment IDNameParts on Todo @fabrix(input: [
  { field: "id", config: { hidden: true } }
]) {
  id
  name
}

query todos {
  allTodos {
    collection {
      ...IDNameParts
      status
   }
  }
}

If field configurations are duplicated between fragments and queries, those are merged into one with queries prioritized.

Fragment registration

Ideally, users can register their own component associated to a fragment.

Component registry is the place that supports those association.

componentRegistry.addFragment(
  query: gql`
    fragmment moKanbanView on ManufacturingOrder {
      collection {
        quantity
        status
        name
        description
      }
    }
  `,
  component: ({ values }) => {
    /*
     * {
     *   collection: {
     *     quantity: number
     *     name: string
     *   }
     * }
     */
    return (
      <Kanban 
        groupBy="status" 
        title="name" 
        body={(value) => (
          <KanbanDescription>
            {value.description}
          </KanbanDescription>
        )}
        values={values} 
      />
    )
  }
)

const Page = () => {
  return (
    <FabrixComponent
      contentClassName="grid gap-1"
      query={gql`
        query {
          manufacturingOrders {
            ...moKanbanView
          }
        }
      `}
    />
  ) 
}
@IzumiSy IzumiSy self-assigned this Oct 17, 2024
@IzumiSy IzumiSy converted this from a draft issue Oct 17, 2024
@IzumiSy IzumiSy closed this as completed by moving to TODO in Fabrix roadmap Oct 17, 2024
@IzumiSy IzumiSy reopened this Oct 17, 2024
@IzumiSy IzumiSy added the feature New feature or request label Oct 17, 2024
@IzumiSy IzumiSy added this to the 2024Q4 milestone Oct 17, 2024
@IzumiSy IzumiSy closed this as completed by moving to TODO in Fabrix roadmap Oct 17, 2024
@IzumiSy IzumiSy reopened this Oct 17, 2024
@IzumiSy IzumiSy moved this from TODO to InProgress in Fabrix roadmap Oct 25, 2024
@IzumiSy IzumiSy changed the title [FEATURE] Fragment Fragment Nov 27, 2024
@IzumiSy IzumiSy moved this from TODO to InProgress in Fabrix roadmap Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
Status: InProgress
Development

No branches or pull requests

1 participant