Skip to content

GraphQL: User sign up required fields #5743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/ParseGraphQLServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3110,7 +3110,7 @@ describe('ParseGraphQLServer', () => {
it('should sign user up', async () => {
const result = await apolloClient.mutate({
mutation: gql`
mutation SignUp($fields: _UserFields) {
mutation SignUp($fields: _UserSignUpFields) {
users {
signUp(fields: $fields) {
sessionToken
Expand Down
37 changes: 37 additions & 0 deletions src/GraphQL/loaders/parseClassTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,43 @@ const load = (parseGraphQLSchema, parseClass) => {
});
parseGraphQLSchema.meType = 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);
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL/loaders/usersMutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const load = parseGraphQLSchema => {
args: {
fields: {
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),
Expand Down