Skip to content

Commit

Permalink
Merge branch 'master' into session-security
Browse files Browse the repository at this point in the history
  • Loading branch information
MadeByMike authored Sep 11, 2019
2 parents 093bd79 + a8e9378 commit 6019546
Show file tree
Hide file tree
Showing 14 changed files with 282 additions and 36 deletions.
220 changes: 220 additions & 0 deletions .changeset/wild-buttons-grab/changes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
{
"releases": [
{ "name": "@keystone-alpha/fields", "type": "major" },
{ "name": "@keystone-alpha/keystone", "type": "major" },
{ "name": "@keystone-alpha/app-admin-ui", "type": "minor" },
{ "name": "@keystone-alpha/app-graphql", "type": "patch" },
{ "name": "@keystone-alpha/test-utils", "type": "patch" }
],
"dependents": [
{
"name": "@keystone-alpha/api-tests",
"type": "patch",
"dependencies": [
"@keystone-alpha/auth-password",
"@keystone-alpha/adapter-knex",
"@keystone-alpha/adapter-mongoose",
"@keystone-alpha/fields",
"@keystone-alpha/keystone",
"@keystone-alpha/app-graphql",
"@keystone-alpha/test-utils"
]
},
{
"name": "@keystone-alpha/demo-project-blog",
"type": "patch",
"dependencies": [
"@keystone-alpha/auth-password",
"@keystone-alpha/fields-markdown",
"@keystone-alpha/fields-wysiwyg-tinymce",
"@keystone-alpha/adapter-mongoose",
"@keystone-alpha/fields",
"@keystone-alpha/keystone",
"@keystone-alpha/app-admin-ui",
"@keystone-alpha/app-graphql"
]
},
{
"name": "@keystone-alpha/demo-project-meetup",
"type": "patch",
"dependencies": [
"@keystone-alpha/auth-password",
"@keystone-alpha/fields-wysiwyg-tinymce",
"@keystone-alpha/adapter-mongoose",
"@keystone-alpha/fields",
"@keystone-alpha/keystone",
"@keystone-alpha/app-admin-ui",
"@keystone-alpha/app-graphql"
]
},
{
"name": "@keystone-alpha/demo-project-todo",
"type": "patch",
"dependencies": [
"@keystone-alpha/adapter-mongoose",
"@keystone-alpha/fields",
"@keystone-alpha/keystone",
"@keystone-alpha/app-admin-ui",
"@keystone-alpha/app-graphql"
]
},
{
"name": "@keystone-alpha/auth-passport",
"type": "patch",
"dependencies": ["@keystone-alpha/fields"]
},
{
"name": "@keystone-alpha/auth-password",
"type": "patch",
"dependencies": ["@keystone-alpha/fields"]
},
{
"name": "@keystone-alpha/example-projects-starter",
"type": "patch",
"dependencies": [
"@keystone-alpha/auth-password",
"@keystone-alpha/adapter-mongoose",
"@keystone-alpha/fields",
"@keystone-alpha/keystone",
"@keystone-alpha/app-admin-ui",
"@keystone-alpha/app-graphql"
]
},
{
"name": "@keystone-alpha/example-projects-todo",
"type": "patch",
"dependencies": [
"@keystone-alpha/adapter-mongoose",
"@keystone-alpha/fields",
"@keystone-alpha/keystone",
"@keystone-alpha/app-admin-ui",
"@keystone-alpha/app-graphql"
]
},
{
"name": "@keystone-alpha/field-content",
"type": "patch",
"dependencies": ["@keystone-alpha/fields"]
},
{
"name": "@keystone-alpha/fields-auto-increment",
"type": "patch",
"dependencies": ["@keystone-alpha/adapter-knex", "@keystone-alpha/fields"]
},
{
"name": "@keystone-alpha/fields-datetime-utc",
"type": "patch",
"dependencies": [
"@keystone-alpha/adapter-knex",
"@keystone-alpha/adapter-mongoose",
"@keystone-alpha/fields"
]
},
{
"name": "@keystone-alpha/fields-markdown",
"type": "patch",
"dependencies": ["@keystone-alpha/fields"]
},
{
"name": "@keystone-alpha/fields-mongoid",
"type": "patch",
"dependencies": [
"@keystone-alpha/adapter-knex",
"@keystone-alpha/adapter-mongoose",
"@keystone-alpha/fields"
]
},
{
"name": "@keystone-alpha/fields-wysiwyg-tinymce",
"type": "patch",
"dependencies": ["@keystone-alpha/fields"]
},
{
"name": "@keystone-alpha/list-plugins",
"type": "patch",
"dependencies": ["@keystone-alpha/fields"]
},
{
"name": "@keystone-alpha/cypress-project-access-control",
"type": "patch",
"dependencies": [
"@keystone-alpha/auth-password",
"@keystone-alpha/adapter-mongoose",
"@keystone-alpha/fields",
"@keystone-alpha/keystone",
"@keystone-alpha/app-admin-ui",
"@keystone-alpha/app-graphql"
]
},
{
"name": "@keystone-alpha/cypress-project-basic",
"type": "patch",
"dependencies": [
"@keystone-alpha/field-content",
"@keystone-alpha/fields-markdown",
"@keystone-alpha/adapter-mongoose",
"@keystone-alpha/fields",
"@keystone-alpha/keystone",
"@keystone-alpha/app-admin-ui",
"@keystone-alpha/app-graphql"
]
},
{
"name": "@keystone-alpha/cypress-project-client-validation",
"type": "patch",
"dependencies": [
"@keystone-alpha/adapter-mongoose",
"@keystone-alpha/fields",
"@keystone-alpha/keystone",
"@keystone-alpha/app-admin-ui",
"@keystone-alpha/app-graphql"
]
},
{
"name": "@keystone-alpha/cypress-project-login",
"type": "patch",
"dependencies": [
"@keystone-alpha/auth-password",
"@keystone-alpha/list-plugins",
"@keystone-alpha/adapter-mongoose",
"@keystone-alpha/fields",
"@keystone-alpha/keystone",
"@keystone-alpha/app-admin-ui",
"@keystone-alpha/app-graphql"
]
},
{
"name": "@keystone-alpha/cypress-project-social-login",
"type": "patch",
"dependencies": [
"@keystone-alpha/auth-passport",
"@keystone-alpha/auth-password",
"@keystone-alpha/adapter-mongoose",
"@keystone-alpha/fields",
"@keystone-alpha/keystone",
"@keystone-alpha/app-admin-ui",
"@keystone-alpha/app-graphql"
]
},
{
"name": "@keystone-alpha/adapter-knex",
"type": "patch",
"dependencies": ["@keystone-alpha/fields-auto-increment", "@keystone-alpha/keystone"]
},
{
"name": "@keystone-alpha/adapter-mongoose",
"type": "patch",
"dependencies": ["@keystone-alpha/fields-mongoid", "@keystone-alpha/keystone"]
},
{
"name": "@keystone-alpha/example-projects-blank",
"type": "patch",
"dependencies": [
"@keystone-alpha/adapter-mongoose",
"@keystone-alpha/keystone",
"@keystone-alpha/app-admin-ui",
"@keystone-alpha/app-graphql"
]
}
]
}
7 changes: 7 additions & 0 deletions .changeset/wild-buttons-grab/changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
`Keystone`, `List` and `Field` constructors now take `schemaNames` as config options. A number of methods also now take `schemaName` parameters.
* `keystone.getTypeDefs()` -> `keystone.getTypeDefs({ schemaName })`
* `keystone.getAdminSchema()` -> `keystone.getAdminSchema({ schemaName })`
* `keystone.dumpSchema(file)` -> `keystone.dumpSchema(file, schemaName)`
* `keystone.getAdminMeta()` -> `keystone.getAdminMeta({ schemaName })`
* `list.getAdminMeta()` -> `list.getAdminMeta({ schemaName })`
* `field.getAdminMeta()` -> `field.getAdminMeta({ schemaName })`
4 changes: 3 additions & 1 deletion packages/app-admin-ui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class AdminUIApp {
pages,
enableDefaultRoute = false,
isAccessAllowed = () => true,
schemaName = 'public',
} = {}) {
if (adminPath === '/') {
throw new Error("Admin path cannot be the root path. Try; '/admin'");
Expand All @@ -34,6 +35,7 @@ class AdminUIApp {
this.graphiqlPath = graphiqlPath;
this.enableDefaultRoute = enableDefaultRoute;
this._isAccessAllowed = isAccessAllowed;
this._schemaName = schemaName;

this.routes = {
signinPath: `${this.adminPath}/signin`,
Expand Down Expand Up @@ -137,7 +139,7 @@ class AdminUIApp {
apiPath: this.apiPath,
graphiqlPath: this.graphiqlPath,
...this.getAdminMeta(),
...keystone.getAdminMeta(),
...keystone.getAdminMeta({ schemaName: this._schemaName }),
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/app-graphql/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class GraphQLApp {
cors = { origin: true, credentials: true },
apiPath = '/admin/api',
graphiqlPath = '/admin/graphiql',
schemaName = 'admin',
schemaName = 'public',
apollo = {},
pinoOptions,
// Deprecated options:
Expand Down
2 changes: 1 addition & 1 deletion packages/app-graphql/lib/apolloServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function createApolloServer(keystone, apolloConfig, schemaName, dev) {
maxFileSize: 200 * 1024 * 1024,
maxFiles: 5,
...apolloConfig,
...keystone.getAdminSchema(),
...keystone.getAdminSchema({ schemaName }),
context: ({ req }) => ({
...keystone.getGraphQlContext({ schemaName, req }),
req,
Expand Down
7 changes: 3 additions & 4 deletions packages/fields/src/Implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Field {
constructor(
path,
{ hooks = {}, isRequired, defaultValue, access, label, schemaDoc, ...config },
{ getListByKey, listKey, listAdapter, fieldAdapterClass, defaultAccess }
{ getListByKey, listKey, listAdapter, fieldAdapterClass, defaultAccess, schemaNames }
) {
this.path = path;
this.isPrimaryKey = path === 'id';
Expand All @@ -30,7 +30,7 @@ class Field {
this.isRelationship = false;

this.access = parseFieldAccess({
schemaNames: ['public'],
schemaNames,
listKey,
fieldKey: path,
defaultAccess,
Expand Down Expand Up @@ -153,8 +153,7 @@ class Field {
get gqlUpdateInputFields() {
return [];
}
getAdminMeta() {
const schemaName = 'public';
getAdminMeta({ schemaName }) {
const schemaAccess = this.access[schemaName];
return this.extendAdminMeta({
label: this.label,
Expand Down
2 changes: 1 addition & 1 deletion packages/fields/src/types/OEmbed/Implementation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const newOEmbed = ({ config = {} } = {}) => {
return new OEmbed(
path,
{ access: true, ...config },
{ listAdapter: { newFieldAdapter: () => {} } }
{ listAdapter: { newFieldAdapter: () => {} }, schemaNames: ['public'] }
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function createRelationship({ path, config = {}, getListByKey = () => new MockLi
listAdapter: new MockListAdapter(),
fieldAdapterClass: MockFieldAdapter,
defaultAccess: true,
schemaNames: ['public'],
});
}

Expand Down
8 changes: 6 additions & 2 deletions packages/fields/tests/Implementation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const args = {
newFieldAdapter: jest.fn(),
},
defaultAccess: true,
schemaNames: ['public'],
};

describe('new Implementation()', () => {
Expand All @@ -21,6 +22,7 @@ describe('new Implementation()', () => {
newFieldAdapter: jest.fn(),
},
defaultAccess: true,
schemaNames: ['public'],
}
);
expect(impl).not.toBeNull();
Expand Down Expand Up @@ -116,8 +118,9 @@ test('gqlOutputFieldResolvers', () => {
describe('getAdminMeta()', () => {
test('meta is as expect', () => {
const impl = new Field('path', { label: 'config label', defaultValue: 'default' }, args);
const schemaName = 'public';

const value = impl.getAdminMeta();
const value = impl.getAdminMeta({ schemaName });
expect(value).toEqual({
access: {
create: true,
Expand All @@ -135,8 +138,9 @@ describe('getAdminMeta()', () => {

test('when defaultValue is a function, forced to `undefined`', () => {
const impl = new Field('path', { label: 'config label', defaultValue: () => 'default' }, args);
const schemaName = 'public';

const value = impl.getAdminMeta();
const value = impl.getAdminMeta({ schemaName });
expect(value).toEqual({
access: {
create: true,
Expand Down
Loading

0 comments on commit 6019546

Please sign in to comment.