fauna-gql-upload icon indicating copy to clipboard operation
fauna-gql-upload copied to clipboard

Feature: add programmatic usage

Open Plazide opened this issue 2 years ago • 3 comments

To further enhance the usability of Fauna GQL Upload, I would like to add support for using it programmatically. The package already exports the upload function, which allows developers to upload one or more specific types of resource programmatically. This is not detailed in the documentation, due to it not being finished or flexible enough.

The implemented usage would have to be significantly more flexible and robust. The following are use cases I would like to see supported:

  • Uploading resources individually and getting response data
  • Uploading resources in batch and getting response data
  • Supplying configuration options, without the need for a config file.
  • Triggering GraphQL Codegen

If you have any suggestions/use cases you'd like to be supported, please leave a comment on this issue.

Plazide avatar Jan 05 '22 21:01 Plazide

Thanks for starting this discussion!

Here are some of my thoughts:

  • I'm thinking at a minimum the abilities of the programmable interface should match the abilities of the command line interface. Some of the features you've listed are already possible via the command line interface, right? Perhaps the first increment of this is just getting parity?
  • Not 100% sure what the value of the codegen is here or the workflow intended. It's the consumer of the GraphQL API that needs the generated code but, depending on how the project is setup, the generated code is written essentially written with the source, not the consumer. The workflow offered by Apollo makes more sense to me.
  • Response data from operations will be useful 👍🏼
    • A use-case: returning the database URL to create the Auth0 API resource (via the Auth0 CLI). I currently make a connection to the Fauna instance after fgu has finished and query the global ID for the database I want to create an Auth0 API resource for. Having this returned by fgu (it already gets logged), would simplify my setup a little and probably make the process faster too.

winghouchan avatar Jan 06 '22 19:01 winghouchan

Regarding codegen, my package.json typically has a script like this and it works fine: fauna-gql && npm run build:gql

What would programmatic usage gain for codegen?

seanconnollydev avatar Jan 18 '22 16:01 seanconnollydev

Well, the built-in support for codegen is for convenience, i.e. not having to setup GraphQL codegen with every new project that uses fauna. But, I can definitely see how this would be redundant to support for programmatic usage. Using the codegen API, like this package does, would give the developer way more flexibility when writing an integration. So, we'll scratch codegen for the time being.

I'm thinking at a minimum the abilities of the programmable interface should match the abilities of the command line interface. Some of the features you've listed are already possible via the command line interface, right? Perhaps the first increment of this is just getting parity?

Feature parity with the CLI should be the goal (I just failed to express that in the initial post). But, I think the first increment could actually be smaller than feature parity. Just getting support for access providers would go a long way. That's the most practical use case I can think of, and would therefore be a good first step.

Plazide avatar Jan 19 '22 14:01 Plazide