Skip to content

Commit

Permalink
Merge branch 'master' into use-db-api
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie committed Apr 26, 2021
2 parents 9609eb3 + c286d7f commit 492b5e7
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 55 deletions.
1 change: 0 additions & 1 deletion docs/components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export function Navigation() {
<NavItem href="/">Welcome</NavItem>
<NavItem href="/whats-new">What's New</NavItem>
<NavItem href="/roadmap">Roadmap</NavItem>
<NavItem href="/faqs">FAQs</NavItem>
<Section label="Tutorials">
<NavItem href="/tutorials/getting-started-with-create-keystone-app">
Getting started
Expand Down
14 changes: 14 additions & 0 deletions docs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ const withMDX = require('@next/mdx')({
},
});

const redirects = {
async redirects() {
// if this array becomes bigger than 3 entries, please make it a separate file
return [
{
source: '/faqs',
destination: '/',
permanent: true,
},
];
},
};

module.exports = withPlugins([
withPreconstruct,
withImages,
Expand All @@ -26,4 +39,5 @@ module.exports = withPlugins([
};
return nextConfig;
},
redirects,
]);
10 changes: 0 additions & 10 deletions docs/pages/faqs.mdx

This file was deleted.

9 changes: 1 addition & 8 deletions packages-next/fields/src/tests/test-fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { getItems } from '@keystone-next/server-side-graphql-client-legacy';
import { KeystoneContext } from '@keystone-next/types';
import { text } from '../types/text';

Expand Down Expand Up @@ -39,13 +38,7 @@ export const filterTests = (withKeystone: any) => {
expected: any[]
) =>
expect(
await getItems({
context,
listKey: 'Test',
where,
returnFields: 'id name',
sortBy: ['name_ASC'],
})
await context.lists.Test.findMany({ where, sortBy: ['name_ASC'], query: 'id name' })
).toEqual(expected);

test(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { getItems } from '@keystone-next/server-side-graphql-client-legacy';
import { KeystoneContext } from '@keystone-next/types';
import { text } from '../../text';
import { autoIncrement } from '..';
Expand Down Expand Up @@ -74,13 +73,7 @@ export const filterTests = (withKeystone: (arg: any) => any, matrixValue: Matrix
const _f = matrixValue === 'ID' ? (x: any) => x.toString() : (x: any) => x;
const match = async (context: KeystoneContext, where: Record<string, any>, expected: any[]) =>
expect(
await getItems({
context,
listKey: 'Test',
where,
returnFields: 'name orderNumber',
sortBy: ['name_ASC'],
})
await context.lists.Test.findMany({ where, sortBy: ['name_ASC'], query: 'name orderNumber' })
).toEqual(expected.map(i => _storedValues[i]));

test(
Expand Down
13 changes: 3 additions & 10 deletions packages-next/fields/src/types/timestamp/tests/test-fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { getItems } from '@keystone-next/server-side-graphql-client-legacy';
import { ProviderName } from '@keystone-next/test-utils-legacy';
import { KeystoneContext } from '@keystone-next/types';
import { text } from '../../text';
Expand Down Expand Up @@ -50,15 +49,9 @@ export const filterTests = (withKeystone: (args: any) => any) => {
expected: any,
sortBy = ['name_ASC']
) =>
expect(
await getItems({
context,
listKey: 'Test',
where,
returnFields: 'name lastOnline',
sortBy,
})
).toEqual(expected);
expect(await context.lists.Test.findMany({ where, sortBy, query: 'name lastOnline' })).toEqual(
expected
);

test(
'Sorting: sortBy: lastOnline_ASC',
Expand Down
13 changes: 5 additions & 8 deletions packages-next/types/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ export type KeystoneContext = {
sudo: () => KeystoneContext;
exitSudo: () => KeystoneContext;
withSession: (session: any) => KeystoneContext;
// TODO: Correctly type this as a prisma client
prisma: any;
images: ImagesContext | undefined;
totalResults: number;
maxTotalResults: number;
schemaName: 'public' | 'internal';
/** @deprecated */
gqlNames: (listKey: string) => Record<string, string>; // TODO: actual keys
/** @deprecated */
keystone: BaseKeystone;
images: ImagesContext | undefined;
} & AccessControlContext &
Partial<SessionContext<any>> &
DatabaseAPIs;
Partial<SessionContext<any>>;

// List item API

Expand Down Expand Up @@ -150,11 +151,7 @@ export type SessionContext<T> = {
endSession(): Promise<void>;
};

// DatabaseAPIs is used to provide access to the underlying database abstraction through
// context and other developer-facing APIs in Keystone, so they can be used easily.
export type DatabaseAPIs = {
prisma?: any;
};
// Images API

export type ImageMode = 'local';

Expand Down
13 changes: 3 additions & 10 deletions tests/api-tests/relationships/crud/one-to-one.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { gen, sampleOne } from 'testcheck';
import { text, relationship } from '@keystone-next/fields';
import { createSchema, list } from '@keystone-next/keystone/schema';
import { multiAdapterRunners, setupFromConfig, testConfig } from '@keystone-next/test-utils-legacy';
import { getItems } from '@keystone-next/server-side-graphql-client-legacy';
import type { ProviderName } from '@keystone-next/test-utils-legacy';
import type { KeystoneContext } from '@keystone-next/types';

Expand Down Expand Up @@ -578,10 +577,8 @@ multiAdapterRunners().map(({ runner, provider }) =>
});

// Make sure the original Company does not point to the location
const result = await getItems({
context,
listKey: 'Location',
returnFields: 'id name company { id }',
const result = await context.lists.Location.findMany({
query: 'id name company { id }',
});
expect(result).toHaveLength(1);

Expand Down Expand Up @@ -625,11 +622,7 @@ multiAdapterRunners().map(({ runner, provider }) =>
});

// Make sure the original Company does not point to the location
const result = await getItems({
context,
listKey: 'Company',
returnFields: 'id location { id }',
});
const result = await context.lists.Company.findMany({ query: 'id location { id }' });
expect(result).toHaveLength(1);

const result1 = await context.lists.Location.findOne({
Expand Down

0 comments on commit 492b5e7

Please sign in to comment.