Cameron
04/30/2020, 4:06 AMyoga
or looking for an example nexus@next
framework project with authentication and graphql-shield
permissions? Check this out: https://github.com/Camji55/nexus-plugin-jwt-auth/tree/master/examples/shield
It utilizes:
Token authentication: nexus-plugin-jwt-auth
https://github.com/Camji55/nexus-plugin-jwt-auth
Permissions: nexus-plugin-shield
https://github.com/lvauvillier/nexus-plugin-shieldAlex Vilchis
04/30/2020, 2:30 PMsubscriptionField
import { subscriptionField } from '@nexus/schema';
import { Context } from '../context';
import { withFilter } from 'apollo-server';
export const Subscription = subscriptionField('onNewEmployeeMessage', {
type: 'EmployeeChatMessage',
subscribe: (root, args, ctx: Context) => {
console.log(ctx);
return withFilter(
() => ctx.pubsub.asyncIterator('onNewEmployeeMessage'),
(payload, variables) => {
return true;
}
);
},
resolve: payload => payload
});
export default Subscription;
I am trying to use Apolloās withFilter function to filter my async iterator results. However, the return type of withType is not what nexus expects in the subscribe field. Any ideas?Ian Wensink
04/30/2020, 2:30 PMtsconfig.json
rdunk
04/30/2020, 10:01 PMrdunk
04/30/2020, 10:03 PMPaul
05/03/2020, 3:56 PMnpm run dev
? It lets me now that server is listening on localhost:4000, however when I open playground at that address I'm getting Server cannot be reached
on the right side of the url field and below error in the graphql response area:
{
"error": "JSON.parse: unexpected character at line 1 column 1 of the JSON data"
}
dependencies:
"dependencies": {
"@types/bcrypt": "^3.0.0",
"@types/jsonwebtoken": "^8.3.9",
"bcrypt": "^4.0.1",
"env-cmd": "^10.1.0",
"jsonwebtoken": "^8.5.1",
"nexus": "^0.21.0-next.21",
"nexus-plugin-prisma": "^0.7.0",
"nexus-plugin-shield": "^0.1.2"
}
Oliver Evans
05/04/2020, 2:25 PMblocka
05/05/2020, 2:09 AMExpected ErrorResponse to be a objectType, saw GraphQLScalarType
This is what I did
const ErrorResponse = objectType({
name: 'ErrorResponse',
definition(t) {
t.string('error')
}
})
const CreatedObjectResponse = objectType({
name: 'CreatedObjectResponse',
definition(t) {
t.id('id')
}
})
const CreateLearningResponse = unionType({
name: 'CreateLearningReponse',
definition(t) {
t.members(ErrorResponse, CreatedObjectResponse)
t.resolveType((e) => (e.error ? ErrorResponse : CreatedObjectResponse))
}
})
When I plug this code into the playground, it works as expectedLars-JĆørgen Kristiansen
05/08/2020, 10:32 AMlewebsimple
05/09/2020, 2:28 AM@nexus/schema
+ nexus-prisma
to work with graphql-modules
? Iām having trouble configuring nexusPrismaPlugin
so it can find the prisma clientlewebsimple
05/09/2020, 2:30 AM@nexus/schema
to work on its own (i.e. without prisma) thoughmjyoung
05/09/2020, 3:45 AMmjyoung
05/09/2020, 3:48 AMnexus-prisma
https://www.nexusjs.org/#/components/schema/plugins/prisma
nexus-plugin-prisma
https://www.nexusjs.org/#/plugins/prisma
Iām not sure what the difference is between the two. I just grabbed nexus-plugin-prisma yesterday and itās working. As in, nexus recognizes it and is able to pull in the client. Have to make sure I donāt have @prisma/client
installed as a dependency since nexus-plugin-prisma
bundles that alreadyJosef Henryson
05/11/2020, 2:28 PMCihad Turhan
05/12/2020, 3:14 PMconst myCustomArg = {
id: stringArg(),
name: stringArg()
}
...
t.field('updateFoo', {
type: 'Bar',
args: {
userId: stringArg(),
custom: myCustomArg
// ^^ I want to use it here
}
...
})
How to use it?
ThanksCihad Turhan
05/12/2020, 4:09 PMconst DeviceInputType = inputObjectType({
name: 'DeviceInputType',
definition(t) {
t.string('id', {nullable: false});
t.field('type', { type: "DeviceType", required: true});
}
});
//and use it as argument:
DeviceInputType.asArg()
Guillermo Lopez
05/16/2020, 5:43 PMRoy
05/16/2020, 9:10 PMmodel Menu {
id Int @default(autoincrement()) @id
name String
company Company @relation(fields: [companyId], references: [id])
companyId Int
isActive Boolean
items ItemOnMenu[]
}
model ItemOnMenu {
id Int @default(autoincrement()) @id
item Item @relation(fields: [itemId], references: [id])
itemId Int
ItemOnOrder ItemOnOrder[]
course String
Menu Menu @relation(fields: [menuId], references: [id])
menuId Int
}
In graphql.ts i have:
schema.objectType({
name: 'Menu',
definition(t) {
t.model.id();
t.model.name();
t.model.items();
t.model.company();
t.model.companyId();
t.model.isActive();
},
});
schema.objectType({
name: 'ItemOnMenu',
definition(t) {
t.model.id();
t.model.item();
t.model.itemId();
t.model.ItemOnOrder();
<http://t.model.Menu|t.model.Menu>();
t.model.menuId();
t.model.course();
t.model.price();
},
});
When i run the following mutation, it will give me an error. The id is in my database, i verified that. This is the mutation:
mutation createNewItemOnMenu(
$item: "test"
$course: "testCourse"
$price: 2.75
) {
createOneItemOnMenu(
data: {
item: { create: { name: $item } }
course: $course
price: $price
Menu: { connect:{id: 60} }
}
) {
id
item {
name
}
}
}
This is the error which gives me a really big headache.
"message": "\n\u001b[31mInvalid \u001b[1m`prisma.itemOnMenu.create()`\u001b[22m invocation:\u001b[39m\n\n Null constraint violation on the fields: (`id`)",
Anyone there who can help me?
I am running:
"@prisma/cli": "^2.0.0-beta.4",
"@prisma/client": "^2.0.0-beta.4",
"nexus-plugin-prisma": "^0.8.0-next.9",
rdunk
05/18/2020, 10:55 AMmutation createOneFoo {
createOneFoo(
data: {
slug: "my-foo"
bars: { create: [{ slug: "my-bar" }] }
bazs: [
{ slug: "my-baz", bar: { connect: { slug: "my-bar" } } }
{ slug: "my-other-baz", bar: { connect: { slug: "my-bar" } } }
]
}
) {
slug
bazs {
slug
bar {
slug
}
}
}
}
rdunk
05/18/2020, 10:58 AMbar
entity, but also create multiple baz
entities and connect them to the created bar
. I seem to get an error like this: AssertionError(\"[Query Graph] Expected a valid parent ID to be present for a nested connect on a one-to-many relation.
but obviously in my case I donāt yet have an ID for the entity I want to connect.rdunk
05/18/2020, 11:30 AMbar
entity, one to create the foo
and baz
entities and connect them to the bar
. I see why now transactions are a wanted feature šrdunk
05/21/2020, 9:52 AMJson
types in your prisma schema? https://github.com/graphql-nexus/nexus/issues/839rdunk
05/21/2020, 9:53 AM@nexus/schema
package doesnāt seem to like JsonAlex Vilchis
05/22/2020, 2:46 PMhasNextPage
from generated prisma-nexus fields? Or is this something I can add through a plugin? Thank youJustin Voitel
05/25/2020, 8:37 PMhuv1k
05/26/2020, 7:04 PMnexus-prisma
regarding prisma?mattadore
05/27/2020, 3:44 AMSamrith Shankar
05/30/2020, 1:30 AMSamrith Shankar
05/30/2020, 2:59 AMError: Query was already defined and imported as a type, check the docs for extending types
I am using queryType
to create my queries and am modularising it in files. How do I do it? And what docs do I read?mjyoung
06/03/2020, 11:28 PMnexus-plugin-prisma
, but im using nexus with prisma and im trying to create a record that has a Json field.Ā (edited)Ā
Iām running into the same error this user experienced:
https://github.com/prisma/prisma-client-js/issues/680
Is nexus-plugin-prisma updated with the latestĀ @prisma/client
?