Skip to content

feat: Add function_name override for endpoints and mutations#265

Open
pranav-new-relic wants to merge 2 commits intomainfrom
feat/endpoint-function-name-override
Open

feat: Add function_name override for endpoints and mutations#265
pranav-new-relic wants to merge 2 commits intomainfrom
feat/endpoint-function-name-override

Conversation

@pranav-new-relic
Copy link
Copy Markdown
Member

Summary

Adds optional function_name field to endpoint and mutation configurations to resolve naming conflicts when multiple endpoints share the same GraphQL field name but exist at different query paths.

Problem

When two queries use endpoints with the same name (e.g., both named workflow), tutone generates conflicting Go functions with identical names, causing compilation errors.

Solution

  • Added function_name field to EndpointConfig and MutationConfig
  • When specified, overrides the generated Go function name while keeping the GraphQL query unchanged
  • Response types are also renamed to match the custom function name

Example Usage

queries:
  - path: ["actor", "account", "workflowAutomation"]
    endpoints:
      - name: workflow
        function_name: accountWorkflow
        max_query_field_depth: 2
  - path: ["actor", "organization", "workflowAutomation"]
    endpoints:
      - name: workflow
        function_name: organizationWorkflow
        max_query_field_depth: 2

Generates:

func (a *Package) GetAccountWorkflow(...) (*AccountWorkflowResponse, error)
func (a *Package) GetOrganizationWorkflow(...) (*OrganizationWorkflowResponse, error)

Testing

  • ✅ Successfully compiles with go build
  • ✅ Backward compatible (field is optional)

🤖 Generated with Claude Code

pranav-new-relic and others added 2 commits March 23, 2026 22:56
Add optional function_name field to EndpointConfig and MutationConfig
to allow overriding the generated Go function name while keeping the
GraphQL field name unchanged. This resolves conflicts when multiple
endpoints share the same name but exist at different paths.

Example usage:
queries:
  - path: ["actor", "account", "workflowAutomation"]
    endpoints:
      - name: workflow
        function_name: accountWorkflow
  - path: ["actor", "organization", "workflowAutomation"]
    endpoints:
      - name: workflow
        function_name: organizationWorkflow

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add .idea/ to gitignore for JetBrains IDEs
- Fix tools.mk: add -e flag to go list to ignore import errors
- Update tools dependencies to match working versions from main

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.

1 participant