graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

feat: new operations-document plugin to generate a GraphQL Document with operations from schema

Open ardatan opened this issue 2 years ago • 13 comments

ardatan avatar Oct 19 '21 09:10 ardatan

🦋 Changeset detected

Latest commit: 320eecb5fad1d9c91917e1ad38bed9568d9ddac8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@graphql-codegen/operations-document Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Oct 19 '21 09:10 changeset-bot[bot]

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/theguild/graphql-code-generator/HRqNze9Akk4B67RwksY3njzYwwz9
✅ Preview: Failed

[Deployment for 320eecb failed]

vercel[bot] avatar Oct 19 '21 09:10 vercel[bot]

The latest changes of this PR are available as alpha in npm (based on the declared changesets):

@graphql-codegen/[email protected]

theguild-bot avatar Oct 19 '21 09:10 theguild-bot

Not being @ardatan , but having exactly this requirement.
For some use cases you need to query all the fields, e. g. when displaying an object relying on the complete data of a type. Having the query/mutation generated saves a lot of work, as you can import it if needed.
If you only need some attributes (which is one of the advantages of GraphQL compared to REST), you can and will define this yourself. For when you need most of the attributes of a type, copying/pasting and then deleting (or importing and adjusting) is a lot easier and safer and quicker than having to write all the query/mutation yourself.

taffit avatar Feb 15 '22 16:02 taffit

I agree with @charlypoly, we should not support this.

Aside from this, I see many weird issues e.g. How would the plugin choose the value of a mandatory field argument?

@taffit your overhead could be reduced by using fragments.

n1ru4l avatar Feb 18 '22 12:02 n1ru4l

It is perfectly fine in my opinion. We have app, where we don't care any data from mutation (we request id only all the time) so this would be great.

homoky avatar Feb 18 '22 12:02 homoky

@taffit your overhead could be reduced by using fragments.

... that you have to write yourself. And maintain and adjust, if something changes. This is what I'm doing currently.
An automatic generation including any changes to the schema would be more helpful in my case. But I can live with either solution.

taffit avatar Feb 18 '22 14:02 taffit

any chance we can get this to generate a file per query / mutation?

davidstellini avatar Mar 11 '22 12:03 davidstellini

Feel free to create a PR based on this branch, I'd love to merge them into this one.

ardatan avatar Mar 11 '22 12:03 ardatan

should we maybe just recommend people to use https://github.com/timqian/gql-generator ? maybe add a recipe to the docs

Urigo avatar Mar 28 '22 17:03 Urigo

@Urigo The only issue with recommending people to use https://github.com/timqian/gql-generator

Is this "feature" that creates invalid output schema- https://github.com/timqian/gql-generator/issues/51

That one plagued me for a few hours while I tried to figure out why the documents were not correct

MDrooker avatar Apr 03 '22 13:04 MDrooker

Hope this get merged. This is definitely useful for testing at least.

NexZhu avatar Jun 06 '22 03:06 NexZhu

this would be nice to have in addition to our custom queries/mutations, wouldn't want to be required to write each one for every use-case

jigz avatar Jul 01 '22 09:07 jigz

Is it going to be merged?

ariel-upstream avatar May 17 '23 07:05 ariel-upstream