ijsto / ijsto/keystone-plugins

Variable "$where" got invalid value { email: "email@email.com" }; Field "email" is not defined by type "UserWhereUniqueInput".

Open
#127 11 comments 0 reactions 1 assignee Claimed by @ScottAgirs View on GitHub
📖 ・docs 📺 ・tutorial candidate good first issue
Dominant language
TypeScript
Stars
8
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Using the example provided in the repo, I get the following error when trying to login to an auth provider (in this case Twitter). I believe the example is out of date as I have only changed the port and DB being used in the case of the example.

`Field "email" is not defined by type "UserWhereUniqueInput".`

This is marked in the URL as such:
```
Variable%20"%24where"%20got%20invalid%20value%20%7B%20email%3A%20"email%40email.com"%20%7D%3B%20Field%20"email"%20is%20not%20defined%20by%20type%20"UserWhereUniqueInput".
```

The keystone config file:

```
import 'dotenv/config';
import { config } from '@keystone-6/core';
import { statelessSessions } from '@keystone-6/core/session';
import Twitter from 'keystone-6-oauth/providers/twitter';
import { createAuth } from 'keystone-6-oauth';
import { KeystoneContext } from '@keystone-6/core/types';
import { lists } from './schemas';
import * as Path from 'path';

let sessionSecret = 'xxxxxxxxxx;

const dbURL = process.env.DATABASE_URL || "file:./keystone.db";

if (!sessionSecret) {
if (process.env.NODE_ENV === 'production') {
throw new Error(
'The SESSION_SECRET environment variable must be set in production'
);
} else {
sessionSecret = '-- DEV COOKIE SECRET; CHANGE ME --';
}
}

const sessionMaxAge = 60 * 60 * 24 * 30; // 30 days

const auth = createAuth({
listKey: 'User',
identityField: 'subjectId',
sessionData: `id name email`,
autoCreate: true,
resolver: async ({user}:{user: any}) => {
const username = user.name as string;
const email = user.email as string;
return { email, username };
},
keystonePath: '/admin',
sessionSecret,
providers: [
Twitter({
clientId: 'xxxxxxxxx',
clientSecret: 'xxxxxxxxxxxx',
}),
],
});

export default auth.withAuth(
// @ts-ignore
config({
server: {
port:3001
},
db: {
provider: "sqlite",
url: dbURL,
},
ui: {
isAccessAllowed: (context: KeystoneContext) => !!context.session?.data,
publicPages: ['/admin/auth/signin', '/admin/auth/error'],
getAdditionalFiles: [
async (config: any) =>
[
{
mode: 'copy',
inputPath: Path.join(__dirname, './customPages/signin.js'),
outputPath: 'pages/auth/signin.js',
},
{
mode: 'copy',
inputPath: Path.join(__dirname, './customPages/error.js'),
outputPath: 'pages/auth/error.js',
}
]
]
},
lists,
session: statelessSessions({
maxAge: sessionMaxAge,
secret: sessionSecret,
}),
})
);
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.