(Prisma) I'm trying to better understand the impor...
# prisma-whats-new
j
(Prisma) I'm trying to better understand the import statement at the top of the schema.graphql. It seems like I can import anything at all and that it will import the whole generated/prisma.graphql file. Is that right, and is that intended to work that way indefinitely? I mostly want to know if I should be individually importing my generated types, or if there's some sort of import * syntax. Could anyone point me towards an issue or documentation on its usage? Thanks!
Of course I immediately saw the information I needed in a post above that linked to https://github.com/graphcool/graphql-import/issues/59
w
Joining in on this as Iโ€™m learning the same thing right now
wondering if itโ€™s possible to just import all the existing mutations for rapid prototyping
n
@wesbos you can use resolver forwarding: https://github.com/graphcool/prisma/tree/master/examples/resolver-forwarding there's also a lot of activity around a potential new feature "addMissingResolvers" which would add all remaining queries and mutations: https://github.com/graphql-binding/graphql-binding/issues/37
w
Thanks! -
forwardTo('db')
n
yes - you will need to enter the operations you want to expose in
src/schema.graphql
d
I am also interested in this topic ๐Ÿ˜…
d
Note that you can do
# import * from "./generated/prisma.graphql"
to import everything into
schema.graphql
. Probably not what you want to do in production. But with
forwardTo('db')
it gets you prototyping quickly.
๐Ÿ‘ 1
@wesbos if you'd just like to import all the Mutations and not Queries/Subscriptions then just add
# import Mutation from "../generated/prisma.graphql"
๐Ÿ‘ 1
๐Ÿ’ก 2
n
good point, thanks for bringing it up @develomark ๐Ÿ™‚
๐Ÿ‘๐Ÿป 1
w
thanks @develomark
any way to merge with my existing mutations in schema.graphql
d
It merges automatically
Run
graphql prepare
on your app schema to see what's generated.
graphql prepare -p app -o src/generated --bundle --save
w
@develomark so I should be able to do this? http://wes.io/pA72
d
Yes
w
hmm okay- doesnโ€™t seem to be visible in playground
d
I've just tested playground and
# import Mutation from "../generated/prisma.graphql"
works
w
allright - thanks - I think ill just stick to forwarding
d
Just run graphql prepare -p app -o src/generated --bundle --save and you'll see what get's merged together. It's pretty smart.
It is undocumented right now, but it is now possible to do
# import Mutation.createPost from "../generated/prisma.graphql"