loader image
Note: Put your heart, mind, and soul into even your smallest acts. This is the secret of success.

How to extend GraphQL Registration in Strapi?

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.

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on whatsapp
WhatsApp
Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp

Nominated in top 10 web developers portfolios

Its a big pleasure to get my portfolio in the best 10 web developers portfolios in @upwork . Is a big work done here and it’s just the half of the way, and big thanks to all clients that got me a chance to grow my portfolio. ✨🙌

Want quick consutling for your project?

the mind that opens to a new idea never returns to its original size.