Skip to content

feat: models only mode#436

Open
amin-farjadi wants to merge 5 commits into
mirumee:mainfrom
amin-farjadi:feat/models-only-mode
Open

feat: models only mode#436
amin-farjadi wants to merge 5 commits into
mirumee:mainfrom
amin-farjadi:feat/models-only-mode

Conversation

@amin-farjadi

Copy link
Copy Markdown

Closes issue #418 and addresses comments on PR #419.

@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cfb9dc49-3ff4-413e-92d7-1fa2e4c23049

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@amin-farjadi
amin-farjadi force-pushed the feat/models-only-mode branch from 7e8fa95 to b7da2c3 Compare June 21, 2026 20:45
@amin-farjadi
amin-farjadi marked this pull request as draft June 21, 2026 20:53
@amin-farjadi
amin-farjadi force-pushed the feat/models-only-mode branch from d91125e to 2a87a1d Compare June 21, 2026 23:26
@amin-farjadi
amin-farjadi marked this pull request as ready for review June 21, 2026 23:34
* origin/main:
  feat: Allow to use custom client for fetching remote schema [AR-2] (mirumee#444)
  feat: add schema_paths for loading schema from local paths and installed packages AR-3 (mirumee#439)
  feat: Allow to use non-httpx HTTP clients in default clients [AR-1] (mirumee#440)
  remove: unnecessary lines
  fix
  fix: tests
  fix: use explicit UTF-8 encoding for ruff format subprocess (mirumee#422) (mirumee#428)
  fix: wrap long lines to satisfy ruff E501
  docs: document multipart_uploads setting in README and configuration guide
  feat: add multipart_uploads setting to disable file upload support

# Conflicts:
#	ariadne_codegen/client_generators/package.py
@amin-farjadi

Copy link
Copy Markdown
Author

hi @DamianCzajkowski would you be able to review this PR?

@DamianCzajkowski

Copy link
Copy Markdown
Collaborator

Hi @amin-farjadi, this feature will definitely be merged. We are currently discussing the features and the future of the codegen, so don’t worry; it will be merged this month. Thank you for contributing!

@Kwaidan00 Kwaidan00 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @amin-farjadi, thank you for your contribution! I left some comments about the overall implementation shape. Please review and let me know if you are planning to apply those changes.

Comment thread ariadne_codegen/config.py
raise MissingConfiguration(f"Config has no [{tool_key}.{codegen_key}] section.")


def get_models_only_settings(config_dict: dict) -> ModelsOnlySettings:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please correct me if I'm wrong, but this function is a copy of get_client_settings with the following changes:

  • return typing
  • settings_fields_names is set based on ModelsOnlySettings
  • returned object is constructed as ModelsOnlySettings instance

I believe there could be a single function which takes the model as parameter and is used for both the client settings and ModelsOnlySettings. Then, there could be two facade functions get_client_settings and get_models_only_settings that returns foo(config_dict, ModelsOnlySettings) or foo(config_dict, ClientSettings).

Comment on lines +475 to +483
base_client_import = generate_import_from(
names=["object"], from_="builtins", level=0
)
client_name = "Client"
base_client = "object"
async_client = True
base_client_file_path = ""
base_client_module_name = ""
client_file_name = "client"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You create a fake objects here just to satisfy the requirement to provide client_generator to PackageGenerator.

However, the strategy you implemented does not need to know anything about client at all - it's the mode without it.

This part of the code and multiple checks if not self.models_only in the generator methods suggest there could be a solution easier to maintain. There should be separate PackageGenerator subclasses: for the client mode and models only mode. Key concepts:

  • most of the logic can be shared in the base class
  • generate method, as the most important function that describes the steps to perform, should be implemented in the subclasses
  • add_operation could live in the base class, the "client mode" class can call super().add_operation and then call the additional self.client_generator.add_method()
  • _validate_unique_file_names can live in the base class, but the subclasses should implement a method to return expected file names
  • similarly, _copy_files can live in the base class, but the subclasses can implement a method to return files to copy
  • finally, the __init__ can share most of the logic, but the "client mode" class can expect additional arguments like client_generator and other client-related settings, unused for "models only" mode.

default_optional_fields_to_none: bool = False
include_typename: bool = True
ignore_extra_fields: bool = True
multipart_uploads: bool = True

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This specific key is used to decide if the base client should contain multipart uploads implementation or not. I think it's the typo to include it here.



@dataclass
class ModelsOnlySettings(BaseSettings):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This model seems to contain a subset of fields defined in ClientSettings. Similarly, the __post_init__ is a shortened copy of ClientSettings.__post_init__.

I think better solution is to create a model e.g. GeneratorSettings(BaseSettings), it will contain the common set of fields and the common logic in __post_init__. Then, ClientSettings and ModelsOnlySettings should inherit GeneratorSettings and optionally add custom logic and additional fields.

DirectiveLocation.ARGUMENT_DEFINITION,
DirectiveLocation.INPUT_FIELD_DEFINITION,
DirectiveLocation.ENUM_VALUE,
DirectiveLocation.DIRECTIVE_DEFINITION,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why did you drop it?

)


class Upload:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This generated example shows the Upload class is not used anywhere (in the client mode, it is used in the client module). I think you can easily change your code to not include the Upload class by using base_model_no_upload.py instead of base_model.py.

Comment thread tests/main/test_main.py
),
"expected_client",
CLIENTS_PATH / "no_multipart_upload" / "expected_client",
),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why did you delete this test case?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants