Skip to content

Commit

Permalink
Merge pull request #1072 from chentsulin/patch-2
Browse files Browse the repository at this point in the history
docs(guide/args): fix object syntax
  • Loading branch information
hayes authored Oct 24, 2023
2 parents 4254773 + 19e9329 commit 3e89a51
Showing 1 changed file with 26 additions and 30 deletions.
56 changes: 26 additions & 30 deletions website/pages/docs/guide/args.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,19 @@ To create a list argument, you can wrap the type in an array or use one of the h
const Query = builder.queryType({
fields: t => ({
giraffeNameChecker: t.booleanList({
{
args: {
names: t.arg.stringList({
required: true,
})
moreNames: t.arg({
type: ['String'],
required: true
})
},
args: {
names: t.arg.stringList({
required: true,
}),
moreNames: t.arg({
type: ['String'],
required: true,
}),
},
resolve: (parent, args) => {
return [...args.names, ...args.moreNames].filter(name => ['Gina', 'James'].includes(name)),
}
})
return [...args.names, ...args.moreNames].filter(name => ['Gina', 'James'].includes(name));
},
}),
}),
});
```
Expand All @@ -154,25 +152,23 @@ You can use `t.arg.listRef` to create a list of lists
```typescript
const Query = builder.queryType({
fields: t => ({
example: t.boolean({
{
args: {
listOfListOfStrings: t.arg({
type: t.arg.listRef(t.arg.listRef('String')),
}),
listOfListOfNullableStrings: t.arg({
type: t.arg.listRef(
// By default listRef creates a list of Non-null items
// This can be overridden by passing in required: false
t.arg.listRef('String', { required: false }),
{ required: true }),
})
},
example: t.boolean({
args: {
listOfListOfStrings: t.arg({
type: t.arg.listRef(t.arg.listRef('String')),
}),
listOfListOfNullableStrings: t.arg({
type: t.arg.listRef(
// By default listRef creates a list of Non-null items
// This can be overridden by passing in required: false
t.arg.listRef('String', { required: false }),
{ required: true }),
}),
},
resolve: (parent, args) => {
return true
}
})
return true;
},
}),
}),
});
```

1 comment on commit 3e89a51

@vercel
Copy link

@vercel vercel bot commented on 3e89a51 Oct 24, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.