Hi guys. I’ve searched something about import type...
# orm-help
a
Hi guys. I’ve searched something about import types from
.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
Copy code
graphql
"""generated.graphql file"""
type ItemWhereInput { ... }

type ItemConnection { ... }

...
I would like to import some types from
generated.graphql
file to
items-types.js
file
Copy code
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
Copy code
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 ahead
f
I use https://www.npmjs.com/package/graphql-cli-generate-fragments It's cli-tool for prisma. Generate fragments only, but i don't need anything else
This is my ugly code for all operations (merge and deploy prisma schema, download them from prisma and generate API-schema with fragments)^ https://github.com/prisma-cms/server/tree/master/src/scripts/deploy
If want to try, git clone https://github.com/prisma-cms/server
yarn endpoint=http://localhost:4466/{project}/{stage} yarn deploy
a
Hey @Fi1osof appreciate your answer. I’ve found a solution reworking some files and using something like the follow:
Copy code
# import * from '../prisma/generated-prisma.graphql'

# import * from './item/item.graphql'
# import * from './user/user.graphql'

scalar DateTime

type Query {
  items: [Item]!
  item(where: ItemWhereUniqueInput!): Item
  users: [User]!
}

type Mutation {
  createItem(input: ItemInput!): Item!
  updateItem(input: ItemUpdateInput!): Item!
  deleteItem(where: ItemWhereUniqueInput!): Boolean
  createUser(input: UserInput!): User!
}
It wasn’t exactly what I was looking for (that is to work just with
.js
files) but It was a faster implementation. When I had some time else I’ll think about it a little more and make some improvements. Thanks again