Skip to content

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

Open
ardatan wants to merge 4 commits into
masterfrom
new-operation-documents
Open

feat: new operations-document plugin to generate a GraphQL Document with operations from schema#6861
ardatan wants to merge 4 commits into
masterfrom
new-operation-documents

Conversation

@ardatan

@ardatan ardatan commented Oct 19, 2021

Copy link
Copy Markdown
Contributor

No description provided.

@changeset-bot

changeset-bot Bot commented Oct 19, 2021

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 320eecb

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

@vercel

vercel Bot commented Oct 19, 2021

Copy link
Copy Markdown

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]

@theguild-bot

theguild-bot commented Oct 19, 2021

Copy link
Copy Markdown
Collaborator

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

@graphql-codegen/operations-document@1.0.0-alpha-17cc8e1de.0

@ardatan ardatan changed the title feat: new operation-documents plugin to generate operation documents from schema feat: new operations-document plugin to generate a GraphQL Document with operations from schema Oct 19, 2021

@charlypoly charlypoly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ardatan

what would be the use-case of this plugin?

I feel it's kind of breaking the design goal of GraphQL by adding all available fields to all operations.
Operations should be built depending on the use-case, otherwise, we're back to good old REST "fetch everything" scenario.

Any thoughts?

@charlypoly charlypoly added the waiting-for-answer Waiting for answer from author label Feb 7, 2022
@taffit

taffit commented Feb 15, 2022

Copy link
Copy Markdown

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.

@n1ru4l

n1ru4l commented Feb 18, 2022

Copy link
Copy Markdown
Collaborator

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.

@homoky

homoky commented Feb 18, 2022

Copy link
Copy Markdown

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.

@taffit

taffit commented Feb 18, 2022

Copy link
Copy Markdown

@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.

@davidstellini

Copy link
Copy Markdown

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

@ardatan

ardatan commented Mar 11, 2022

Copy link
Copy Markdown
Contributor Author

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

@Urigo

Urigo commented Mar 28, 2022

Copy link
Copy Markdown
Collaborator

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

@MDrooker

MDrooker commented Apr 3, 2022

Copy link
Copy Markdown

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

Is this "feature" that creates invalid output schema-
timqian/gql-generator#51

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

@charlypoly charlypoly added status/parked This task has been temporarily parked - No work is currently underway and removed waiting-for-answer Waiting for answer from author labels Apr 4, 2022
@NexZhu

NexZhu commented Jun 6, 2022

Copy link
Copy Markdown

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

@jigz

jigz commented Jul 1, 2022

Copy link
Copy Markdown

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

@ariel-upstream

Copy link
Copy Markdown

Is it going to be merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/parked This task has been temporarily parked - No work is currently underway

Projects

None yet

Development

Successfully merging this pull request may close these issues.