Spectrum doesn't look very alive, so I'll post it ...
# prisma-client
y
Spectrum doesn't look very alive, so I'll post it here as well 🙂 Hey guys, I'm not sure if it's a bug or I'm doing something wrong, please confirm. I use postgres connector (but I've checked mysql as well and still the same issue) and prisma typescript-client generator. After I deploy my datamodel which is very simple and looks like this:
Copy code
type Member {
  id: ID! @unique
  currentBalance: Float!
  transactions: [Transaction!]
  retailers: [Retailer!]
}

type Retailer {
  id: ID! @unique
  name: String!
}

type Transaction {
  id: ID! @unique
  purchaseDate: DateTime!
  rewardedDate: DateTime!
}
typescript-client generates interface without relational fields.
Copy code
export interface Member {
  id: ID_Output;
  currentBalance: Float;
}
So some of my resolvers don't have necessary types 😞 Anyone already faced this? Thanks in advance!
d
Can you create a small reproduction repository with minimal code and post an issue here: https://github.com/prisma/prisma/issues/new/choose
y
@divyendu you can actually try it on the simplest example https://github.com/prisma/prisma-examples/tree/master/typescript/graphql Just checked it and the issue is still there datamodel contains
Post
relation
Copy code
type User {
  id: ID! @unique
  email: String! @unique
  name: String
  posts: [Post!]!
}
the generator output:
Copy code
export interface User {
  id: ID_Output;
  email: String;
  name?: String;
}
d
I think you need to do something like:
prisma.user().posts({...relational filters are here})
They are not on the top level because:
prisma.users()
or
prisma.user()
only resolves the scalar types!
y
Actually I want to do smt like this:
Copy code
import {
  GraphQLFloat,
  GraphQLID,
  GraphQLList,
  GraphQLObjectType,
} from 'graphql';

import { Member, Retailer, Transaction } from '../../generated/prisma-client';
import GraphQLRetailer from './Retailer';
import GraphQLTransaction from './Transaction';

export default new GraphQLObjectType({
  name: 'Member',
  fields: {
    id: {
      type: GraphQLID,
      resolve: ({ id }: Member): string => id,
    },
    currentBalance: {
      type: GraphQLFloat,
      resolve: ({ currentBalance }: Member): number => currentBalance,
    },
    transactions: {
      type: new GraphQLList(GraphQLTransaction),
      resolve: ({ transactions }: Member): Transaction[] => transactions,
    },
    retailers: {
      type: new GraphQLList(GraphQLRetailer),
      resolve: ({ retailers }: Member): Retailer[] => retailers,
    },
  },
});
so I have types for:
Copy code
transactions: {
      type: new GraphQLList(GraphQLTransaction),
      resolve: ({ transactions }: Member): Transaction[] => transactions,
    },
    retailers: {
      type: new GraphQLList(GraphQLRetailer),
      resolve: ({ retailers }: Member): Retailer[] => retailers,
    },
and at the moment Member doesn't have a transactions or retailers fields
d
y
yes, that's probably it, thanks a lot!