Shopify/syrup

Reduce generated TypeScript selection data.

samrmur opened this issue · 0 comments

Currently, the selection structure generated by Syrup for TypeScript uses null, empty objects, or empty arrays for selection elements that essentially empty or non-existent. Since selections already take up a large portion of bundle size, we can improve the generated code by only defining what we actually need.

Old Selection Structure

export interface GraphSelection {
  name: string
  arguments: Record<string, any>
  type: TypeDefinition
  passedGID: string | null
  typeCondition: TypeDefinition | null
  directive: ConditionalDirective | null
  selections: GraphSelection[]
}

Potential New Selection Structure

export interface GraphSelection {
  name: string
  type: TypeDefinition
  typeCondition: TypeDefinition
  arguments?: Record<string, any>
  passedGID?: string
  directive?: ConditionalDirective
  selections?: GraphSelection[]
}