Hello Everyone,
This is a small blog about something related to Strapi exactly in the powerful part of this CMS is the GraphQL, I was working on a mobile app built with react native and we using Strapi as backend but I stuck on the registration part with GraphQL because we have some extended information, not just the default ones
{ username: "username", email: "email", password: "password" })
But we have a full name, phone, birthday, and address as mandatory to be the user registered in our platform.
So how can I solve this problem? to add more inputs to my GraphQL mutation because without it we will need to add this info after the registration or with a relation input inside the backend.
So let’s extend our schema
First go to “./extensions/users-permissions/config/”
Create a file “schema.graphql.js” //if you don’t have it
Then make a module that defines your new schema to extend the user permissions input
module.exports = { definition: ` extend input UsersPermissionsRegisterInput { fullName: String!, …. //write more input’s } `, type: {}, resolver: {}, };
So after you restart your server you can post a new GraphQL mutation to register a new user with extended information
//Exemple for a mutation mutation { register(input: { fullName: “fullName” username: "username", email: "email", password: "password" }) { jwt user { fullName username email } } }
Thank you for watch and I hope you share it with your friends.