graphile / graphile/crystal

Allow documenting function parameters via smart-comments

Open
#1,419 1 comment 2 reactions 0 assignees View on GitHub
✨ feature 🤩 good-first-bug
Dominant language
TypeScript
Stars
12.9k
Forks
625
Avg merge
5h 23m
Merged PRs (30d)
24

Description

### Feature description

Support to document the function parameters on graphql.

* currently it only lists the parameters
* defaults are not shown in the documentation
* no difference between required parameters (those not having a default) and optional parameters (those having a default)

### Motivating example

currently it seems there is no way to document function parameters using smart comments

```
create or replace function create_chart_event(
title text,
chart_size int,
submission_start timestamptz default null,
)
returns foo as
$$
...
$$ language sql volatile;

comment on function create_chart_event is
E'Creates a chart event where users can vote on something';

```

it would help users of the api if we could document each parameter.

eg:

```
comment on parameter create_chart_event.submission_start is
E'Datetime users can start submitting their votes, defaults to now if not given';
```

unfortunately it seems postgres does not support comments on function parameters.

so something like this might work (similar to [jsonfield](https://www.graphile.org/postgraphile/smart-comments/#smart-comment-spec)):

```
comment on function create_chart_event is
E'Creates a chart event where users can vote on something\n'
'@param submission_start Datetime users can start submitting their votes, defaults to now if not given';
```

also, in the above example title and chart_size should be recognized as required inputs whereas submission_start is optional

```
type CreateChartEventInput {
title: String!
chartSize: Int!

"""
Datetime users can start submitting their votes, defaults to now if not given
"""
submissionStart: Datetime
}
```

### Supporting development

I [tick all that apply]:

- [ ] am interested in building this feature myself
- [ ] am interested in collaborating on building this feature
- [x] am willing to help testing this feature before it's released
- [ ] am willing to write a test-driven test suite for this feature (before it exists)
- [ ] am a [Graphile sponsor](https://www.graphile.org/sponsor/) ❤️
- [ ] have an active [support or consultancy contract](https://www.graphile.org/support/) with Graphile

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.