Skip to content

feat(gen): support proto_paths for gen graphql through proto file - #3206

Merged
tusharmath merged 2 commits into
tailcallhq:mainfrom
DLillard0:feature/support-proto-paths
Dec 9, 2024
Merged

feat(gen): support proto_paths for gen graphql through proto file#3206
tusharmath merged 2 commits into
tailcallhq:mainfrom
DLillard0:feature/support-proto-paths

Conversation

@DLillard0

@DLillard0 DLillard0 commented Dec 7, 2024

Copy link
Copy Markdown
Contributor

Summary:

Currently, when using the tailcall gen command to process proto files, the import path is fixed to a relative path, but in the protobuf import syntax, you can specify the path to find the dependency using the -I/--proto_path flag. So, most proto projects are currently organized in this way, and I think we also need to support it.

{
  "inputs": [
    {
      "proto": {
        "src": "./proto/apps/mian.proto",
        "url": "http://localhost:8080",
        // new params
        "protoPaths": ["./proto/apps"]
      }
    }
  ],
  "preset": {
    "mergeType": 1.0
  },
  "output": {
    "path": "./output/main.graphql",
    "format": "graphQL"
  },
  "schema": {
    "query": "Query"
  }
}

Issue Reference(s):

None

Build & Testing:

  • I ran cargo test successfully.
  • I have run ./lint.sh --mode=fix to fix all linting issues raised by ./lint.sh --mode=check.

Checklist:

  • I have added relevant unit & integration tests.
  • I have updated the documentation accordingly.
  • I have performed a self-review of my code.
  • PR follows the naming convention of <type>(<optional scope>): <title>

@github-actions github-actions Bot added the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Dec 7, 2024
@tusharmath

Copy link
Copy Markdown
Contributor

Can't we use src to specify the protoPath instead of creating a new field?

@DLillard0

DLillard0 commented Dec 7, 2024

Copy link
Copy Markdown
Contributor Author

proto_path specifies the search path for dependent files in src file.
I think they should have different meanings.

file path: proto/apps/notification_center/api/v1/audience.proto

syntax = "proto3";
package notification_center.api.v1;

import "notification_center/types/v1/model.proto";

dependence import "notification_center/types/v1/model.proto" now it will be parsed as proto/apps/notification_center/api/v1/notification_center/types/v1/model.proto

using "protoPaths": ["./proto/apps"] it will be parsed as proto/apps/notification_center/types/v1/model.proto

@codecov

codecov Bot commented Dec 7, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 96.77419% with 2 lines in your changes missing coverage. Please review.

Project coverage is 86.75%. Comparing base (fe220be) to head (6340d95).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/core/proto_reader/reader.rs 95.45% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3206      +/-   ##
==========================================
+ Coverage   86.73%   86.75%   +0.01%     
==========================================
  Files         278      278              
  Lines       27918    27963      +45     
==========================================
+ Hits        24214    24258      +44     
- Misses       3704     3705       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment thread src/core/proto_reader/reader.rs
Comment thread src/cli/generator/config.rs
@tusharmath
tusharmath force-pushed the feature/support-proto-paths branch from 424b746 to 6bcd740 Compare December 8, 2024 16:59
@DLillard0
DLillard0 force-pushed the feature/support-proto-paths branch from 6bcd740 to bf6e377 Compare December 9, 2024 03:00
@tusharmath
tusharmath force-pushed the feature/support-proto-paths branch from bf6e377 to 9bcf429 Compare December 9, 2024 05:43
@tusharmath tusharmath added the ci: lint Automatically fix the linters issues and make a commit label Dec 9, 2024
@tusharmath
tusharmath force-pushed the feature/support-proto-paths branch from 9bcf429 to 61cd2a4 Compare December 9, 2024 06:05
@tusharmath
tusharmath enabled auto-merge (squash) December 9, 2024 06:05
@tusharmath
tusharmath force-pushed the feature/support-proto-paths branch from e8783d3 to 6340d95 Compare December 9, 2024 06:47
@tusharmath
tusharmath merged commit 858ac97 into tailcallhq:main Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci: lint Automatically fix the linters issues and make a commit type: feature Brand new functionality, features, pages, workflows, endpoints, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants