<link rel="stylesheet" href="/_merged_assets/_static/search/noscript.css">
Apollo Elements Apollo Elements Guides API Blog Toggle darkmode

Generator: Component

Generate an Apollo Element

Example

npm init @apollo-elements -- \
  component \
    --type mutation \
    --name x-user-profile \
    --operation-name UpdateProfile
    --variables '$input: UpdateProfileInput!' \
    --fields 'updateProfile(input: $input) { id }' \
    --subdir user \
    --schema-path '#schema' \
    --shared-css-path '#components/shared.css' \
    --no-codegen
    --overwrite

Options

FlagDescriptionTypeDefault
--helpShow helpboolean
--versionShow version numberboolean
--pkg-managerPreferred package managernpm|yarnnpm
--type, -tElement typequery|mutation| subscriptionquery
--name, -nCustom element tag namestring
--subdir, -dOptional subdir under src/componentsstring
--overwriteOverwrite existing filesbooleanfalse
--codegenRun codegen after scaffolding filesbooleantrue
--schema-pathOptional custom path to schema types filestring
--shared-css-pathOptional custom path to shared component styles filestring
--variablesOptional custom variables e.g. input: $UpdateUserInputstring
--fieldsOptional custom fields e.g. id name picture { alt url }string