Skip to content

apollo client:download fails if OUTPUT doesn't exist #1788

@mayteio

Description

@mayteio

Intended outcome:
Should download the schema file, then put it in the OUTPUT argument, even if the folder specified doesn't exist.

Actual outcome:
My cli command:
apollo client:download-schema ./src/__generated__/schema.json fails when __generated__ folder doesn't exist.

How to reproduce the issue:
pass a filepath with a folder that doesn't exist as the OUTPUT .

I can trace that back the writeFileSync call in download-schema.ts as the culprit, where writeFileSync will throw if a folder doesn't exist.

This stackoverflow article points to two solutions - one using mkdirp and one using fs-extra, or this answer without additional packages. I would like to contribute a fix to this (if you'll have one) and was wondering if there was a preference on how to solve it? Or maybe this is desired behaviour?

I believe this is important because we store generated artifacts in a __generated__ folder, which we do not want to check into github.

Any help appreciated!

Versions
apollo/2.22.0 darwin-x64 node-v13.6.0

Possibly related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions