adroaldof
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 aheadFi1osof
10/23/2018, 9:57 PMFi1osof
10/23/2018, 10:00 PMFi1osof
10/23/2018, 10:01 PMFi1osof
10/23/2018, 10:01 PMadroaldof
11/05/2018, 7:48 PM# 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