GraphQL: User sign up required fields (#5743)
This commit is contained in:
committed by
Antonio Davi Macedo Coelho de Castro
parent
60d9327a78
commit
3d63545ab7
@@ -3110,7 +3110,7 @@ describe('ParseGraphQLServer', () => {
|
|||||||
it('should sign user up', async () => {
|
it('should sign user up', async () => {
|
||||||
const result = await apolloClient.mutate({
|
const result = await apolloClient.mutate({
|
||||||
mutation: gql`
|
mutation: gql`
|
||||||
mutation SignUp($fields: _UserFields) {
|
mutation SignUp($fields: _UserSignUpFields) {
|
||||||
users {
|
users {
|
||||||
signUp(fields: $fields) {
|
signUp(fields: $fields) {
|
||||||
sessionToken
|
sessionToken
|
||||||
|
|||||||
@@ -551,6 +551,43 @@ const load = (parseGraphQLSchema, parseClass) => {
|
|||||||
});
|
});
|
||||||
parseGraphQLSchema.meType = meType;
|
parseGraphQLSchema.meType = meType;
|
||||||
parseGraphQLSchema.graphQLTypes.push(meType);
|
parseGraphQLSchema.graphQLTypes.push(meType);
|
||||||
|
|
||||||
|
const userSignUpInputTypeName = `_UserSignUpFields`;
|
||||||
|
const userSignUpInputType = new GraphQLInputObjectType({
|
||||||
|
name: userSignUpInputTypeName,
|
||||||
|
description: `The ${userSignUpInputTypeName} input type is used in operations that involve inputting objects of ${className} class when signing up.`,
|
||||||
|
fields: () =>
|
||||||
|
classCustomFields.reduce(
|
||||||
|
(fields, field) => {
|
||||||
|
const type = mapInputType(
|
||||||
|
parseClass.fields[field].type,
|
||||||
|
parseClass.fields[field].targetClass,
|
||||||
|
parseGraphQLSchema.parseClassTypes
|
||||||
|
);
|
||||||
|
if (type) {
|
||||||
|
return {
|
||||||
|
...fields,
|
||||||
|
[field]: {
|
||||||
|
description: `This is the object ${field}.`,
|
||||||
|
type:
|
||||||
|
field === 'username' || field === 'password'
|
||||||
|
? new GraphQLNonNull(type)
|
||||||
|
: type,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ACL: defaultGraphQLTypes.ACL_ATT,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
});
|
||||||
|
parseGraphQLSchema.parseClassTypes[
|
||||||
|
'_User'
|
||||||
|
].signUpInputType = userSignUpInputType;
|
||||||
|
parseGraphQLSchema.graphQLTypes.push(userSignUpInputType);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const load = parseGraphQLSchema => {
|
|||||||
args: {
|
args: {
|
||||||
fields: {
|
fields: {
|
||||||
descriptions: 'These are the fields of the user.',
|
descriptions: 'These are the fields of the user.',
|
||||||
type: parseGraphQLSchema.parseClassTypes['_User'].classGraphQLInputType,
|
type: parseGraphQLSchema.parseClassTypes['_User'].signUpInputType,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
type: new GraphQLNonNull(defaultGraphQLTypes.SIGN_UP_RESULT),
|
type: new GraphQLNonNull(defaultGraphQLTypes.SIGN_UP_RESULT),
|
||||||
|
|||||||
Reference in New Issue
Block a user