Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

prints independent operation name#393

Open
vasilich6107 wants to merge 2 commits into
heftapp:main from
artflutter:print-independent-operation-name
Open

prints independent operation name #393
vasilich6107 wants to merge 2 commits into
heftapp:main from
artflutter:print-independent-operation-name

Conversation

@vasilich6107

@vasilich6107 vasilich6107 commented May 21, 2025
edited
Loading

Copy link
Copy Markdown
Contributor

Hi @budde377

this PR adds printing of an independent operation name for the cases when we do not use graphql and graphql_flutter clients.

For example when we use https://github.com/artflutter/graphql_flutter_bloc and want to pass operationName to WatchQueryOptions
https://github.com/artflutter/graphql_flutter_bloc/blob/master/test/query_bloc_test.dart#L26

I see that there is a class WatchOptions$Query but it is being generated only in case if we add client generation.

Copy link
Copy Markdown
Contributor Author

One more thing that we probably could try is...

@vasilich6107 vasilich6107 force-pushed the print-independent-operation-name branch from a0fb3e7 to 3c0cd0d Compare May 21, 2025 08:53
@vasilich6107 vasilich6107 force-pushed the print-independent-operation-name branch from 3c0cd0d to 4ab9e58 Compare May 21, 2025 08:54

Copy link
Copy Markdown
Contributor Author

This is it

Added an ability to access the operation name via static variable operationNameDefinition which is useful in tests for mocking purposes

smth like

if(oprationName == WatchQueryOptions.operationNameDefinition) {
 // then return some mock
}

Copy link
Copy Markdown
Contributor Author

If this approach makes sense for you I will finish the tests

Copy link
Copy Markdown
Contributor

Thanks for suggesting this @vasilich6107! Some minor suggestions:

I think it would make sense to store the operation name next to the document node, e.g.

const documentNodeMutationX = ...
const operantionNameMutationX = ...

That way you will always generate the operation name regardless of the client being present.

You can still expose it as you suggest on the options.

I would be nice if we are consistent on exposing it across the options, also the watch-options.

A protip for getting the tests updated would be to

  1. Update the packages/graphql_codegen/test/builder_test.dart file to make the test override the files.
  2. Run tests.
  3. Review the new files.
  4. Change back the lines above.

Copy link
Copy Markdown
Contributor Author

Hi @budde377
Could you check the fixes

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /