Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argument need not be optional to have a default value defined #1703

Open
wants to merge 1 commit into
base: source
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pages/learn/schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type Starship {

All arguments are named. Unlike languages like JavaScript and Python where functions take a list of ordered arguments, all arguments in GraphQL are passed by name specifically. In this case, the `length` field has one defined argument, `unit`.

Arguments can be either required or optional. When an argument is optional, we can define a _default value_ - if the `unit` argument is not passed, it will be set to `METER` by default.
Arguments can be either required or optional. We can define a _default value_ for an argument as well - if the `unit` argument is not passed, it will be set to `METER` by default.
Copy link
Member

Choose a reason for hiding this comment

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

How about:

Suggested change
Arguments can be either required or optional. We can define a _default value_ for an argument as well - if the `unit` argument is not passed, it will be set to `METER` by default.
Arguments can be either required or optional. An argument is optional if its type is nullable or if it defines a _default value_. For the `length` field above, if the `unit` argument is not passed, it will be set to `METER` by default.

I think the code above should also be adjusted (and this change reflected as appropriate in the rest of the page), though that is not essential:

  length(unit: LengthUnit! = METER): Float

Copy link
Member

Choose a reason for hiding this comment

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

(The change being the addition of the !)


## The Query and Mutation types

Expand Down
Loading