Julien Goux
02/15/2021, 1:49 PM// What I have currently
export const createTask = mutationField("createTask", {
args: {
input: nonNull(
inputObjectType({
definition(t) {
t.nonNull.string("name");
},
name: "CreateTaskInput",
})
),
},
resolve(_root, args, ctx) {
},
type: task,
});
// What I'd like
mutationField("createTask", {
input(t) {
t.nonNull.string("name");
}
resolve() {},
type: task
})
Julien Goux
02/15/2021, 1:49 PMJulien Goux
02/15/2021, 1:50 PMJulien Goux
02/15/2021, 1:52 PM${capitalize(mutationName)}Input
blocka
02/15/2021, 1:59 PMDavidT
02/17/2021, 6:46 PMDaniell
02/22/2021, 9:00 AMDaniell
02/22/2021, 9:08 AMChris
02/23/2021, 12:38 AMcuid()
). Is there any examples that implements this with Prisma, and if not how would I be able to somehow add this metadata to the ID, so that I can avoid having to query all tables.Lars-Jørgen Kristiansen
02/23/2021, 7:48 AMconst Query = queryType({
definition(t) {
t.field("lower", {
type: nonNull("String"),
args: { name: "String" },
resolve: (_root, { name }) => name.toLowerCase(),
});
},
});
Can it protect me from doing this? It should be able to figure out that name can be optional..Hafffe
02/23/2021, 6:18 PMexport const ContactTag = objectType({
name: 'ContactTag',
definition(t) {
t.int('id');
t.string('label');
t.string('color');
}
});
// Error
t.string('color');
Expected 2 arguments, but got 1.ts(2554)
definitionBlocks.d.ts(473, 55): Arguments for the rest parameter 'config' were not provided.
both label and color are just two optional strings in my prisma schema. And I can't understand why they differ.. any tips are welcome 🙂Meiri Anto
02/24/2021, 3:00 AMMeiri Anto
02/24/2021, 3:01 AMCustomer
through relations, the same rule will be enforced?Victor
02/25/2021, 2:18 AM2.17
👋 Hey guys, after updating to the latest version of Prisma I have found that the generated types from nexus
and makeSchema
contains an error when using `sourceTypes` to configure backing types, see the code below I use to do so.
sourceTypes: {
modules: [
{
module: require.resolve('.prisma/client/index.d.ts'),
alias: 'Prisma',
},
],
},
However, when doing this the generated types has a type error, related to Prisma.SortOrder
, see below.
export interface NexusGenEnums {
SortOrder: Prisma.SortOrder // <-- this is the error, see below
}
// Namespace '<ROOT>/node_modules/.prisma/client/index"' has no exported member 'SortOrder'
I can fix this by manually changing it to this:
export interface NexusGenEnums {
SortOrder: Prisma.Prisma.SortOrder // <-- this fixes it
}
The underlying issue seems to be that in the latest version of Prisma, SortOrder is no longer exported at the top level. It is exported under the namespace Prisma. Comparing 2.17
v.s 2.13
below.
2.17 - node_modules/.prisma/client/index.d.ts
export namespace Prisma {
// ... a lot of stuff here
export const SortOrder: {
asc: 'asc',
desc: 'desc'
};
export type SortOrder = (typeof SortOrder)[keyof typeof SortOrder]
}
2.13 - node_modules/.prisma/client/index.d.ts
// ..same as above, but also exports type SortOrder, mentioning that it is deprecated
/**
* @deprecated Renamed to `Prisma.SortOrder`
*/
export type SortOrder = Prisma.SortOrder
Jonathan
02/26/2021, 12:09 PMJulien Goux
02/26/2021, 10:02 PMmaxweld
03/01/2021, 9:32 AM$ npm run test
> workshop@1.0.0 test C:\Users\david\Documents\My-Computing-Projects\Prisma-GraphQL-TS-Auth\workshop
> npm run generate && jest
> workshop@1.0.0 generate C:\Users\david\Documents\My-Computing-Projects\Prisma-GraphQL-TS-Auth\workshop
> ts-node --transpile-only api/schema
FAIL tests/Post.test.ts (18.357 s)
× ensures that a draft can be created and published (12658 ms)
● ensures that a draft can be created and published
assert.fail(received, expected)
Message:
unknown message code: 4a
at Parser.handlePacket (node_modules/pg-protocol/src/parser.ts:198:16)
at Parser.parse (node_modules/pg-protocol/src/parser.ts:101:30)
at Socket.<anonymous> (node_modules/pg-protocol/src/index.ts:7:48)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 2 passed, 2 total
Time: 18.535 s
Ran all test suites.
(node:136420) UnhandledPromiseRejectionWarning: Error: Caught error after test environment was torn down
Connection terminated unexpectedly
(Use `node --trace-warnings ...` to show where the warning was created)
(node:136420) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see <https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode>). (rejection id: 1)
(node:136420) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! workshop@1.0.0 test: `npm run generate && jest`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the workshop@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\david\AppData\Roaming\npm-cache\_logs\2021-02-28T10_07_48_829Z-debug.log
Any ideas are appreciated. Thanks
Secondary issue
Also I found the Github repository to be in a bit of a confusing state.:
a) Two .env files. The one in the root directory is not used, the one in the /prisma directory is.
b) There is a file in the /tests directory which I cannot find referenced in either the code or the tutorial (nexus-test-environment.js). It can probably be removed.
c) In the /api/graphql/Posts.ts file there are a number of Interfaces/objectTypes which are not used (Media, Movie, Song).
It does not add to the confidence in the tutorial or solution when you find these artefacts.Meiri Anto
03/03/2021, 3:10 AM{set: value}
For example, in Prisma a model's UpdateInput
type for a given string field is a union type:
fullName?: NullableStringFieldUpdateOperationsInput | string | null
but the Nexus-Prisma's generated graphql type has the field type restricted to
fullName: NullableStringFieldUpdateOperationsInput
Julien Goux
03/04/2021, 5:06 PMJulien Goux
03/04/2021, 5:07 PMMax Streitberger
03/07/2021, 9:22 AMit("ensures that only the host can modify an event", async () => {
await createTestUser(ctx, "Test", "User", "<mailto:test@test.com|test@test.com>", "mySecretPassword")
const event = await createTestEvent(ctx, event_data.title, event_data.description, when, address)
console.log(ctx.client)
ctx.client.setHeader("authorization", "")
await createTestUser(ctx, "Test2", "User2", "<mailto:test@test2.com|test@test2.com>", "mySecretPassword2")
console.log(ctx.client)
async function modifyEvent() {
const modified_event_response = await ctx.client.request(gql`
mutation updateDescription($event_id: String!) {
updateDescription(event_id: $event_id, description: "This is the updated description.") {
event_id
description
}
}
`,{ event_id: event.event_id }
);
return modified_event_response
}
expect(modifyEvent()).toThrow("Sorry, but you are not allowed to do this")
})
But when I try to run this test, I get this error:
FetchError: request to <http://localhost:4000/> failed, reason: connect ECONNREFUSED 127.0.0.1:4000
Does someone have an idea of how to solve this?Mikastark
03/10/2021, 10:58 AMnexus-prisma
plugin (0.24.0-next.1) but when I want to generate (npx prisma generate
) I get this error "`nexus-prisma` is no longer a generator. You can read more at https://pris.ly/nexus-prisma-upgrade-0.4". What I'm doing wrong ?
package.json (partial)
"dependencies": {
"@prisma/client": "~2.17.0",
"graphql": "^15.5.0",
"nexus": "^1.0.0",
"nexus-prisma": "^0.24.0-next.1"
},
"devDependencies": {
"prisma": "~2.17.0",
"typescript": "^4.2.3"
},
prisma/schema.prisma
generator client {
provider = "prisma-client-js"
}
generator nexusPrisma {
provider = "nexus-prisma"
}
Mark
03/10/2021, 2:31 PMconst app = express();
const server = new ApolloServer({
schema: schema,
context: createContext,
})
const adminServer = new ApolloServer({
schema: adminSchema,
context: createContext,
})
server.applyMiddleware({ app, path: '/graphql', cors: true });
adminServer.applyMiddleware({ app, path: '/admin', cors: true });
The issue seems to be that the Typescript compilation fails because the Nexus generated types exist in two separate places, and there are overlaps.
Does anyone know if this has any chance of working, and if so, how should I manage it?Daniell
03/11/2021, 1:49 PMPhilipp Humburg
03/11/2021, 7:11 PMDregond
03/14/2021, 6:02 AMBen Walker
03/14/2021, 10:08 PMDaniell
03/15/2021, 9:11 AMDregond
03/16/2021, 4:57 AMJulien Goux
03/17/2021, 10:12 AM