hinsxd
10/23/2018, 12:33 PMwhere:{ title_contains }
does not provide case-insensitive search, and I cant perform raw sql queries with Client neither.hinsxd
10/23/2018, 12:34 PMWhite
10/23/2018, 1:41 PMRick Perko
10/23/2018, 1:53 PMadroaldof
10/23/2018, 5:29 PM.graphql
files. I’ve found [graphql-import](https://github.com/prisma/graphql-import) to import using # import something from 'something-else'
. This works fine between .graphql
files.
But what I’m trying to do is to import some types
from generated.graphql
from Prisma into a .js
file.
For example:
I have this generated.graphql
file from Prisma
graphql
"""generated.graphql file"""
type ItemWhereInput { ... }
type ItemConnection { ... }
...
I would like to import some types from generated.graphql
file to items-types.js
file
javascript
// items-types.js file
import gql from 'graphql-tag';
// I would like to make some kind of import ItemWhereInput and ItemConnection here
// Something like `import { ItemWhereInput, ItemConnection } from 'generated.graphql'`
...
const ItemWhereUniqueInput = gql`
input ItemWhereUniqueInput {
id: String!
}
`;
...
// And export ItemWhereInput and ItemConnection here
export default [Item, ItemInput, ItemWhereUniqueInput, ItemUpdateInput];
That way I could call makeExecutableSchema
from graphql-tools
and use those types in some place else
javascript
// items-query.js file
import { forwardTo } from 'prisma-binding';
const schema = `
items: [Item]!
item (where: ItemWhereUniqueInput!): Item
# And use it here
itemsConnection (where: ItemWhereInput): ItemConnection!
`;
const resolvers = {
items: forwardTo('db'),
item: forwardTo('db'),
itemsConnection: forwardTo('db'),
};
export default {
schema,
resolvers,
};
If it is somewhere else or there are something that could help, please, point me out.
Thanks aheadJoseph Carrington
10/23/2018, 7:55 PMJoseph Carrington
10/23/2018, 7:56 PMChanges:
PortalCart (Type)
~ Updated field `owner`
Applying changes (2/1) ⣯
dieff
10/23/2018, 8:27 PMIf I don't cast the argument `any` then I get the error ```Argument of type '{ where: { AND: ({ mutation_in: string[]; } | { node: { user: { id: string; }; }; })[]; }; }' is not assignable to parameter of type 'NotificationSubscriptionWhereInput'.
Object literal may only specify known properties, and 'where' does not exist in type 'NotificationSubscriptionWhereInput'
The code works as it is now even with the error. If I take away the where
property, and just make the AND
as the first key then I get no typescript error but the code will not work. Maybe the generated types are incorrect? Also possible I'm just using the library wrong.shadowcodex
10/23/2018, 10:03 PMshadowcodex
10/23/2018, 10:42 PMshadowcodex
10/23/2018, 10:42 PMshadowcodex
10/23/2018, 10:50 PMshadowcodex
10/24/2018, 12:19 AMElfayer
10/24/2018, 6:23 AMElfayer
10/24/2018, 6:23 AMHays Clark
10/24/2018, 7:15 AMcreatedAt: DateTime!
and updatedAt: DateTime!
values by Seeding or Import your data? I’m trying to write a parser that is importing data from other data sources and it would be nice not to have to make a ‘created_at’, and ‘updated_at’ property…doums
10/24/2018, 9:10 AMtype PostSubscriptionPayload {
mutation: MutationType!
node: Post
updatedFields: [String!]
previousValues: PostPreviousValues
}
from one subscription like
type Subscription {
posts: PostSubscriptionPayload
}
?
I tried this:
posts: {
subscribe: async (parent, args, ctx) => {
return ctx.prisma.$<http://subscribe.post|subscribe.post>()
},
resolve: payload => {
console.log(payload)
return payload
}
}
But in the resolve function I receive only the mutation Type, all others fields are null, whatever is the mutation type.nuno
10/24/2018, 9:37 AMmezie
10/24/2018, 10:06 AMThanos
10/24/2018, 10:06 AMdebug:false
on server options but it didn't have any effect. Thank you.Pieter
10/24/2018, 10:31 AMPieter
10/24/2018, 10:32 AM@InputField{isNullable:true})
my mutation still expects all params as required.Pieter
10/24/2018, 10:33 AM?
optional type on typescript but still does not workYash Rathore
10/24/2018, 11:46 AMYash Rathore
10/24/2018, 11:49 AMtheom
10/24/2018, 12:31 PMYou must wrap the query string in a "gql" tag.
error when calling refreshQueries. What am I overlooking here?
pagination.js
const PAGINATION_QUERY = gql`
query PAGINATION_QUERY {
itemsConnection {
aggregate {
count
}
}
}
`;
export { PAGINATION_QUERY };
createItem.js
import deleteItemsFromCache from '../utils/deleteItemsFromCache';
import PAGINATION_QUERY from './Pagination';
update = (cache, payload) => {
deleteItemsFromCache
};
<Mutation
mutation={CREATE_ITEM_MUTATION}
variables={this.state}
update={this.update}
refetchQueries={[{ query: PAGINATION_QUERY }]}
>
wontwon
10/24/2018, 3:24 PMdoums
10/24/2018, 6:08 PMtype PostSubscriptionPayload {
mutation: MutationType!
node: Post
updatedFields: [String!]
previousValues: PostPreviousValues
}
Because when I try with something like that in the resolver return ...prisma.$<http://subscribe.post|subscribe.post>()
and I console log the returned payload of this, I get PostSubscriptionPayload
but only updatedFields
and mutation
fields are set correctly, the other fields remains null, whatever is the event (creation, delete, update).
Second problem, and this is a big one because it concerns the DELETE subscription, we can't get back the previous value of the deleted node at all! If I try ctx.prisma.$<http://subscribe.post|subscribe.post>({ mutation_in: ['DELETED'] }).previousValues()
with
type Subscription {
deletedPost: PostPreviousValues! // I tested with Post! too, same error
}
I get null
Note that I console log the payload in the resolve
function of each subscription resolver like
deletedPost: {
subscribe: async (parent, args, ctx) => {
return ctx.prisma.$<http://subscribe.post|subscribe.post>({ mutation_in: ['DELETED'] }).previousValues()
},
resolve: payload => {
console.log(payload)
return payload
}
}
So I'm pretty sure the problem comes from prisma Client 🤪
prisma 1.19 (docker image as well)Guus
10/24/2018, 8:50 PMRamm
10/24/2018, 10:32 PM