Skip to content

Commit

Permalink
Merge branch 'master' into MadeByMike-CI-always-run-linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jesstelford authored Jan 15, 2020
2 parents f4f9328 + 51500a8 commit 3eaa10e
Show file tree
Hide file tree
Showing 42 changed files with 1,222 additions and 371 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,15 @@
"contributions": [
"bug"
]
},
{
"login": "justintemps",
"name": "Justin Smith",
"avatar_url": "https://avatars3.githubusercontent.com/u/12401179?v=4",
"profile": "https://github.com/justintemps",
"contributions": [
"doc"
]
}
],
"contributorsPerLine": 7,
Expand Down
6 changes: 0 additions & 6 deletions .changeset/bright-garlics-sleep.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/chatty-walls-give.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/dull-taxis-relax.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/fair-cheetahs-add.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/green-bees-learn.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/lazy-hats-begin.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/odd-ladybugs-look.md

This file was deleted.

7 changes: 7 additions & 0 deletions .changeset/shaggy-dingos-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@keystonejs/demo-project-blog': patch
'@keystonejs/demo-project-meetup': patch
'@keystonejs/app-next': patch
---

Bump next.js dep to ^9.2.0
5 changes: 0 additions & 5 deletions .changeset/twelve-mugs-design.md

This file was deleted.

1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center"><a href="https://ginkgoch.com"><img src="https://avatars1.githubusercontent.com/u/41072618?v=4" width="80px;" alt=""/><br /><sub><b>Ginkgoch</b></sub></a><br /><a href="https://github.com/keystonejs/keystone/commits?author=ginkgoch" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/MaisaMilena"><img src="https://avatars2.githubusercontent.com/u/28612369?v=4" width="80px;" alt=""/><br /><sub><b>MaisaMilena</b></sub></a><br /><a href="https://github.com/keystonejs/keystone/commits?author=MaisaMilena" title="Documentation">📖</a></td>
<td align="center"><a href="http://www.marxvn.com"><img src="https://avatars2.githubusercontent.com/u/4975208?v=4" width="80px;" alt=""/><br /><sub><b>Martin Pham</b></sub></a><br /><a href="https://github.com/keystonejs/keystone/issues?q=author%3Amarxvn" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://github.com/justintemps"><img src="https://avatars3.githubusercontent.com/u/12401179?v=4" width="80px;" alt=""/><br /><sub><b>Justin Smith</b></sub></a><br /><a href="https://github.com/keystonejs/keystone/commits?author=justintemps" title="Documentation">📖</a></td>
</tr>
</table>

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ We'd like to start by thanking all our wonderful contributors:
<td align="center"><a href="https://ginkgoch.com"><img src="https://avatars1.githubusercontent.com/u/41072618?v=4" width="80px;" alt=""/><br /><sub><b>Ginkgoch</b></sub></a><br /><a href="https://github.com/keystonejs/keystone/commits?author=ginkgoch" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/MaisaMilena"><img src="https://avatars2.githubusercontent.com/u/28612369?v=4" width="80px;" alt=""/><br /><sub><b>MaisaMilena</b></sub></a><br /><a href="https://github.com/keystonejs/keystone/commits?author=MaisaMilena" title="Documentation">📖</a></td>
<td align="center"><a href="http://www.marxvn.com"><img src="https://avatars2.githubusercontent.com/u/4975208?v=4" width="80px;" alt=""/><br /><sub><b>Martin Pham</b></sub></a><br /><a href="https://github.com/keystonejs/keystone/issues?q=author%3Amarxvn" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://github.com/justintemps"><img src="https://avatars3.githubusercontent.com/u/12401179?v=4" width="80px;" alt=""/><br /><sub><b>Justin Smith</b></sub></a><br /><a href="https://github.com/keystonejs/keystone/commits?author=justintemps" title="Documentation">📖</a></td>
</tr>
</table>

Expand Down
100 changes: 99 additions & 1 deletion api-tests/relationships/crud/many-to-many-no-ref.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,41 @@ const getCompanyAndLocation = async (keystone, companyId, locationId) => {
return data;
};

const createReadData = async keystone => {
// create locations [A, A, B, B, C, C];
const { data } = await graphqlRequest({
keystone,
query: `mutation create($locations: [LocationsCreateInput]) { createLocations(data: $locations) { id name } }`,
variables: {
locations: ['A', 'A', 'B', 'B', 'C', 'C'].map(name => ({ data: { name } })),
},
});
const { createLocations } = data;
await Promise.all(
[
[0, 1, 2, 3, 4, 5], // -> [A, A, B, B, C, C]
[0, 2, 4], // -> [A, B, C]
[0, 1], // -> [A, A]
[0, 2], // -> [A, B]
[0, 4], // -> [A, C]
[2, 3], // -> [B, B]
[0], // -> [A]
[2], // -> [B]
[], // -> []
].map(async locationIdxs => {
const ids = locationIdxs.map(i => ({ id: createLocations[i].id }));
const { data } = await graphqlRequest({
keystone,
query: `mutation create($locations: [LocationWhereUniqueInput]) { createCompany(data: {
locations: { connect: $locations }
}) { id locations { name }}}`,
variables: { locations: ids },
});
return data.createCompany;
})
);
};

multiAdapterRunners().map(({ runner, adapterName }) =>
describe(`Adapter: ${adapterName}`, () => {
// 1:1 relationships are symmetric in how they behave, but
Expand Down Expand Up @@ -99,7 +134,7 @@ multiAdapterRunners().map(({ runner, adapterName }) =>
[createListsLR, 'Left -> Right'],
[createListsRL, 'Right -> Left'],
].forEach(([createLists, order]) => {
describe(`One-to-one relationships - ${order}`, () => {
describe(`Many-to-many relationships - ${order}`, () => {
function setupKeystone(adapterName) {
return setupServer({
adapterName,
Expand All @@ -108,6 +143,69 @@ multiAdapterRunners().map(({ runner, adapterName }) =>
});
}

describe('Read', () => {
test(
'_some',
runner(setupKeystone, async ({ keystone }) => {
await createReadData(keystone);
await Promise.all(
[
['A', 6],
['B', 5],
['C', 3],
['D', 0],
].map(async ([name, count]) => {
const { data } = await graphqlRequest({
keystone,
query: `{ allCompanies(where: { locations_some: { name: "${name}"}}) { id }}`,
});
expect(data.allCompanies.length).toEqual(count);
})
);
})
);
test(
'_none',
runner(setupKeystone, async ({ keystone }) => {
await createReadData(keystone);
await Promise.all(
[
['A', 3],
['B', 4],
['C', 6],
['D', 9],
].map(async ([name, count]) => {
const { data } = await graphqlRequest({
keystone,
query: `{ allCompanies(where: { locations_none: { name: "${name}"}}) { id }}`,
});
expect(data.allCompanies.length).toEqual(count);
})
);
})
);
test(
'_every',
runner(setupKeystone, async ({ keystone }) => {
await createReadData(keystone);
await Promise.all(
[
['A', 3],
['B', 3],
['C', 1],
['D', 1],
].map(async ([name, count]) => {
const { data } = await graphqlRequest({
keystone,
query: `{ allCompanies(where: { locations_every: { name: "${name}"}}) { id }}`,
});
expect(data.allCompanies.length).toEqual(count);
})
);
})
);
});

describe('Create', () => {
test(
'With connect',
Expand Down
100 changes: 99 additions & 1 deletion api-tests/relationships/crud/many-to-many.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,41 @@ const getCompanyAndLocation = async (keystone, companyId, locationId) => {
return data;
};

const createReadData = async keystone => {
// create locations [A, A, B, B, C, C];
const { data } = await graphqlRequest({
keystone,
query: `mutation create($locations: [LocationsCreateInput]) { createLocations(data: $locations) { id name } }`,
variables: {
locations: ['A', 'A', 'B', 'B', 'C', 'C'].map(name => ({ data: { name } })),
},
});
const { createLocations } = data;
await Promise.all(
[
[0, 1, 2, 3, 4, 5], // -> [A, A, B, B, C, C]
[0, 2, 4], // -> [A, B, C]
[0, 1], // -> [A, A]
[0, 2], // -> [A, B]
[0, 4], // -> [A, C]
[2, 3], // -> [B, B]
[0], // -> [A]
[2], // -> [B]
[], // -> []
].map(async locationIdxs => {
const ids = locationIdxs.map(i => ({ id: createLocations[i].id }));
const { data } = await graphqlRequest({
keystone,
query: `mutation create($locations: [LocationWhereUniqueInput]) { createCompany(data: {
locations: { connect: $locations }
}) { id locations { name }}}`,
variables: { locations: ids },
});
return data.createCompany;
})
);
};

multiAdapterRunners().map(({ runner, adapterName }) =>
describe(`Adapter: ${adapterName}`, () => {
// 1:1 relationships are symmetric in how they behave, but
Expand Down Expand Up @@ -101,7 +136,7 @@ multiAdapterRunners().map(({ runner, adapterName }) =>
[createListsLR, 'Left -> Right'],
[createListsRL, 'Right -> Left'],
].forEach(([createLists, order]) => {
describe(`One-to-one relationships - ${order}`, () => {
describe(`Many-to-many relationships - ${order}`, () => {
function setupKeystone(adapterName) {
return setupServer({
adapterName,
Expand All @@ -110,6 +145,69 @@ multiAdapterRunners().map(({ runner, adapterName }) =>
});
}

describe('Read', () => {
test(
'_some',
runner(setupKeystone, async ({ keystone }) => {
await createReadData(keystone);
await Promise.all(
[
['A', 6],
['B', 5],
['C', 3],
['D', 0],
].map(async ([name, count]) => {
const { data } = await graphqlRequest({
keystone,
query: `{ allCompanies(where: { locations_some: { name: "${name}"}}) { id }}`,
});
expect(data.allCompanies.length).toEqual(count);
})
);
})
);
test(
'_none',
runner(setupKeystone, async ({ keystone }) => {
await createReadData(keystone);
await Promise.all(
[
['A', 3],
['B', 4],
['C', 6],
['D', 9],
].map(async ([name, count]) => {
const { data } = await graphqlRequest({
keystone,
query: `{ allCompanies(where: { locations_none: { name: "${name}"}}) { id }}`,
});
expect(data.allCompanies.length).toEqual(count);
})
);
})
);
test(
'_every',
runner(setupKeystone, async ({ keystone }) => {
await createReadData(keystone);
await Promise.all(
[
['A', 3],
['B', 3],
['C', 1],
['D', 1],
].map(async ([name, count]) => {
const { data } = await graphqlRequest({
keystone,
query: `{ allCompanies(where: { locations_every: { name: "${name}"}}) { id }}`,
});
expect(data.allCompanies.length).toEqual(count);
})
);
})
);
});

describe('Create', () => {
test(
'With connect',
Expand Down
2 changes: 1 addition & 1 deletion api-tests/relationships/crud/one-to-many-no-ref.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ multiAdapterRunners().map(({ runner, adapterName }) =>
[createListsLR, 'Left -> Right'],
[createListsRL, 'Right -> Left'],
].forEach(([createLists, order]) => {
describe(`One-to-one relationships - ${order}`, () => {
describe(`One-to-many relationships - ${order}`, () => {
function setupKeystone(adapterName) {
return setupServer({
adapterName,
Expand Down
Loading

0 comments on commit 3eaa10e

Please sign in to comment.