Skip to content

Commit

Permalink
Merge pull request #964 from nathanchapman/patch-1
Browse files Browse the repository at this point in the history
Update Simple Objects plugin documentation
  • Loading branch information
hayes authored Jul 20, 2023
2 parents c486fdc + 8e10601 commit 5e9e5b7
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions website/pages/docs/plugins/simple-objects.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const ContactInfo = builder.simpleObject('ContactInfo', {
email: t.string({
nullable: false,
}),
phoneNUmber: t.string({
phoneNumber: t.string({
nullable: true,
}),
}),
Expand All @@ -63,23 +63,26 @@ const Node = builder.simpleInterface('Node', {
}),
});

const UserType = builder.simpleObject('User', {
interfaces: [Node],
fields: (t) => ({
firstName: t.string(),
lastName: t.string(),
contactInfo: t.field({
type: ContactInfo,
nullable: false,
const UserType = builder.simpleObject(
'User',
{
interfaces: [Node],
fields: (t) => ({
firstName: t.string(),
lastName: t.string(),
contactInfo: t.field({
type: ContactInfo,
nullable: false,
}),
}),
},
// You can add additional fields with resolvers with a third fields argument
(t) => ({
fullName: t.string({
resolve: (user) => `${user.firstName} ${user.lastName}`,
}),
}),
}),
// You can add aditional fields with resolvers with a third fields argument
(t) => ({
fullName: t.string({
resolve: (user) => `${user.firstName} ${user.lastName}`,
}),
})
});
);

builder.queryType({
fields: (t) => ({
Expand All @@ -95,7 +98,7 @@ builder.queryType({
lastName: 'Organa',
contactInfo: {
email: '[email protected]',
phoneNUmber: null,
phoneNumber: null,
},
};
},
Expand Down

1 comment on commit 5e9e5b7

@vercel
Copy link

@vercel vercel bot commented on 5e9e5b7 Jul 20, 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.