Hi!
Im missing documentation on how to use the GraphQL extensionService
. I have added an media field on the user called profile_image
and I want to return it when calling me
and on login
etc in GraphQL.
I have text fields as well, which return fine. now Im stuck with the media field.
I have this in my index:
register({ strapi }) {
const extensionService = strapi.service("plugin::graphql.extension");
extensionService.use(({ nexus }) => ({
types: [
nexus.extendType({
type: 'UsersPermissionsMe',
definition(t) {
// here define fields you need
t.string('first_name');
t.string('last_name');
t.string('profile_image', {
type: 'UploadFileEntityResponse',
resolve: async (root, args) => {
const userData = await strapi.db.query('plugin::users-permissions.user').findOne({
select: [],
where: { id: root.id },
populate: { profile_image: true },
});
const { toEntityResponse } = strapi.plugin('graphql').service('format').returnTypes;
console.dir(userData.profile_image)
return toEntityResponse(userData.profile_image ?? null, {
args,
resourceUID: "plugin::uploads.uploads",
})
},
});
},
}),
]
}));
},
I can now create this query, but the profile image data
is always `null:
query fetchMe {
me {
id
email
first_name
last_name
profile_image {
data {
id
attributes {
url
}
}
}
}
}
It’s probably because of the wrong resourceUID
in toEntityResponse
but I have no clue on what to use there. Is there a list of options somewhere? Is this documented?