Skip to content
Permalink
Browse files Browse the repository at this point in the history
fix: turns off automerging new people (#1989)
* fix: turns off automerging new people

* fix

* tests and snaps
  • Loading branch information
redreceipt committed Jun 14, 2021
1 parent a2b62f6 commit cb5f8f1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Expand Up @@ -224,11 +224,12 @@ describe('Auth', () => {
});

it('creates user profile', async () => {
context.dataSources.Person.create = jest.fn(() => 35);
const result = await context.dataSources.Auth.createUserProfile({
email: 'isaac.hardy@newspring.cc',
});

expect(result).toEqual('35');
expect(result).toEqual(35);
});

it('throws error in createUserProfile', async () => {
Expand Down Expand Up @@ -276,6 +277,7 @@ describe('Auth', () => {
}
}
`;
context.dataSources.Person.create = jest.fn(() => 1);

const rootValue = {};

Expand Down
Expand Up @@ -7,19 +7,13 @@ Array [
Array [
"/People",
Object {
"BirthDay": 1,
"BirthMonth": 2,
"BirthYear": 2020,
"FirstName": "Vincent",
"Gender": 1,
"Gender": 0,
"IsSystem": false,
},
],
]
`;

exports[`Person creates a profile 2`] = `Object {}`;

exports[`Person gets person from aliasId: The call to fetch the alias id 1`] = `
Array [
Array [
Expand Down
11 changes: 8 additions & 3 deletions packages/apollos-data-connector-rock/src/people/data-source.js
Expand Up @@ -65,13 +65,18 @@ export default class Person extends RockApolloDataSource {
return null;
};

create = (profile) => {
create = async (profile) => {
const rockUpdateFields = this.mapApollosFieldsToRock(profile);
return this.post('/People', {
// auto-merge functionality is compromised
// we are creating a new user and patching them with profile details
const id = await this.post('/People', {
Gender: 0, // required by Rock. Listed first so it can be overridden.
...rockUpdateFields,
IsSystem: false, // required by rock
});
await this.patch(`/People/${id}`, {
...rockUpdateFields,
});
return id;
};

mapGender = ({ gender }) => {
Expand Down

0 comments on commit cb5f8f1

Please sign in to comment.