You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Note: All types implementing a queryable interface must also implement the `Node` interface
1103
-
1104
-
## Extending third-party types
1105
-
1106
-
So far, the examples have been dealing with types created from locally available data.
1107
-
However, Gatsby also allows to integrate and modify third-party GraphQL schemas.
1108
-
1109
-
Usually, those third-party schemas are retrieved from remote sources via introspection
1110
-
query with Gatsby's `gatsby-source-graphql` plugin. To customize types integrated from
1111
-
a third-party schema, you can use the [`createResolvers`](/docs/reference/config-files/gatsby-node/#createResolvers) API.
1112
-
1113
-
### Feeding remote images into `gatsby-image`
1114
-
1115
-
As an example, you could look at [using-gatsby-source-graphql](https://github.com/gatsbyjs/gatsby/blob/master/examples/using-gatsby-source-graphql/gatsby-node.js) to see how you could use `createResolvers` to feed images from a CMS into `gatsby-image` (the assumption is that `gatsby-source-graphql` was configured
1116
-
to prefix all types from the third-party schema with `CMS`):
1117
-
1118
-
```js:title=gatsby-node.js
1119
-
exports.createResolvers= ({
1120
-
actions,
1121
-
cache,
1122
-
createNodeId,
1123
-
createResolvers,
1124
-
store,
1125
-
reporter,
1126
-
}) => {
1127
-
const { createNode } = actions
1128
-
createResolvers({
1129
-
CMS_Asset: {
1130
-
imageFile: {
1131
-
type:`File`,
1132
-
resolve(source, args, context, info) {
1133
-
returncreateRemoteFileNode({
1134
-
url:source.url,
1135
-
store,
1136
-
cache,
1137
-
createNode,
1138
-
createNodeId,
1139
-
reporter,
1140
-
})
1141
-
},
1142
-
},
1143
-
},
1144
-
})
1145
-
}
1146
-
```
1147
-
1148
-
You create a new `imageFile` field on the `CMS_Asset` type, which will create `File`
1149
-
nodes from every value on the `url` field. Since `File` nodes automatically have
1150
-
`childImageSharp` convenience fields available, you can then feed the images from the CMS
1151
-
into `gatsby-image` by querying:
1152
-
1153
-
```graphql
1154
-
query {
1155
-
cms {
1156
-
post {
1157
-
# In this example, the `post.image` field is of type `CMS_Asset`
1158
-
image {
1159
-
# It is important to include all fields in the query which you want to
1160
-
# access in the resolver. In this example make sure to include
1161
-
# the `url` field. In the future, Gatsby might provide a `@projection`
1162
-
# extension to automatically include those fields.
Copy file name to clipboardExpand all lines: docs/docs/reference/release-notes/migrating-from-v3-to-v4.md
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -252,6 +252,8 @@ The recommended approach is to always create nodes in `sourceNodes`. We are goin
252
252
this workaround that will work using `sourceNodes`. It is still being worked on, please post your use-cases and ideas
253
253
in [this discussion](https://github.com/gatsbyjs/gatsby/discussions/32860#discussioncomment-1262874) to help us shape this new APIs.
254
254
255
+
If you've used this with `gatsby-source-graphql`, please switch to [Gatsby GraphQL Source Toolkit](https://github.com/gatsbyjs/gatsby-graphql-toolkit). Generally speaking you'll want to create your own source plugin to fully support such use cases.
256
+
255
257
You can also learn more about this in the [migration guide for source plugins](/docs/reference/release-notes/migrating-source-plugin-from-v3-to-v4/#2-data-mutations-need-to-happen-during-sourcenodes-or-oncreatenode).
0 commit comments