Skip to content

Commit 8dc2955

Browse files
authored
fix(docs/mutations-and-input-types.mdx): root being inside of SDL (#4452)
The example shows graphql implementation, where the "root" is by mistake put as string as part of the schema definition instead being a native js const BEFORE (root is undefined and wongly put into the schema itself): ![image](https://github.com/user-attachments/assets/3908e84e-1c3e-43b5-8633-163ea66fdfa0) AFTER (root correctly defined outside of the schema): ![image](https://github.com/user-attachments/assets/e14d51cc-2f36-450d-aea8-384d6c6a0703)
1 parent 7134cab commit 8dc2955

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

website/pages/docs/mutations-and-input-types.mdx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -230,26 +230,6 @@ type Query {
230230
getMessages: [Message]
231231
}
232232
233-
const root = {
234-
getMessage: ({ id }) => {
235-
return fakeDatabase[id]
236-
},
237-
getMessages: () => {
238-
return Object.values(fakeDatabase)
239-
},
240-
createMessage: ({ input }) => {
241-
const id = String(Object.keys(fakeDatabase).length + 1)
242-
const message = new Message(id, input)
243-
fakeDatabase[id] = message
244-
return message
245-
},
246-
updateMessage: ({ id, input }) => {
247-
const message = fakeDatabase[id]
248-
Object.assign(message, input)
249-
return message
250-
}
251-
}
252-
253233
type Mutation {
254234
createMessage(input: MessageInput): Message
255235
updateMessage(id: ID!, input: MessageInput): Message
@@ -265,6 +245,26 @@ class Message {
265245
}
266246
}
267247

248+
const root = {
249+
getMessage: ({ id }) => {
250+
return fakeDatabase[id]
251+
},
252+
getMessages: () => {
253+
return Object.values(fakeDatabase)
254+
},
255+
createMessage: ({ input }) => {
256+
const id = String(Object.keys(fakeDatabase).length + 1)
257+
const message = new Message(id, input)
258+
fakeDatabase[id] = message
259+
return message
260+
},
261+
updateMessage: ({ id, input }) => {
262+
const message = fakeDatabase[id]
263+
Object.assign(message, input)
264+
return message
265+
}
266+
}
267+
268268
const app = express();
269269
app.all(
270270
'/graphql',

0 commit comments

Comments
 (0)