Skip to content

Commit 697e6f4

Browse files
authored
docs(gatsby): image cdn author docs tweak (#35451)
* provide full schema customization example * Update creating-a-source-plugin.md
1 parent 3fb8642 commit 697e6f4

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

docs/docs/how-to/plugins-and-themes/creating-a-source-plugin.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,20 +1027,23 @@ It is also recommended that you add a polyfill to provide support back through G
10271027
```js
10281028
import { addRemoteFilePolyfillInterface } from "gatsby-plugin-utils/polyfill-remote-file"
10291029
1030-
addRemoteFilePolyfillInterface(
1031-
schema.buildObjectType({
1032-
name: `YourImageAssetNodeType`,
1033-
fields: {
1034-
// your fields
1035-
},
1036-
interfaces: [`Node`, `RemoteFile`],
1037-
}),
1038-
{
1039-
schema,
1040-
actions,
1041-
// schema and actions are arguments on the `createSchemaCustomization` API
1042-
}
1043-
)
1030+
exports.createSchemaCustomization = ({ actions, schema }) => {
1031+
const imageAssetType = addRemoteFilePolyfillInterface(
1032+
schema.buildObjectType({
1033+
name: `YourImageAssetNodeType`,
1034+
fields: {
1035+
// your fields - see createSchemaCustomization docs - if you're using schema inference you can also leave this object empty
1036+
},
1037+
interfaces: [`Node`, `RemoteFile`],
1038+
}),
1039+
{
1040+
schema,
1041+
actions,
1042+
}
1043+
)
1044+
1045+
actions.createTypes([imageAssetType])
1046+
}
10441047
```
10451048
10461049
Implementing the `RemoteFile` interface adds the correct fields to your new GraphQL type and adds the necessary resolvers to handle the type. `RemoteFile` holds the following properties:

0 commit comments

Comments
 (0)