Skip to content

Commit

Permalink
chore(docs): custom names for connection plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
migueloller committed Jan 6, 2021
1 parent d1b2b52 commit a79087a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions docs/content/030-plugins/01-connection.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,33 @@ const schema = makeSchema({
],
})
```

## Custom names for Connection / Edge types

You can provide a function to generate a custom name for connection and edge types. The function will receive the field and parent type names.

### Globally

```ts
connectionPlugin({
getConnectionName(fieldName, parentTypeName) {
return `${parentTypeName}${upperFirst(fieldName)}Connection`
},
getEdgeName(fieldName, parentTypeName) {
return `${parentTypeName}${upperFirst(fieldName)}Edge`
},
})
```

### One-off / per-field

```ts
t.connectionField('users', {
getConnectionName(fieldName, parentTypeName) {
return `${parentTypeName}${upperFirst(fieldName)}Connection`
},
getEdgeName(fieldName, parentTypeName) {
return `${parentTypeName}${upperFirst(fieldName)}Edge`
},
})
```

0 comments on commit a79087a

Please sign in to comment.