prisma-labs / graphql-framework-experiment

Code-First Type-Safe GraphQL Framework
https://nexusjs.org
MIT License
673 stars 66 forks source link

Transform TS Types to Nexus GraphQL types #469

Open Weakky opened 4 years ago

Weakky commented 4 years ago

Description

When plugging external data-sources into your GraphQL API, it might become fairly cumbersome to convert/map all the TS types of that datasource to actual Nexus GraphQL types.

Ideas

1) Small utility tools to convert TS types to Nexus GraphQL types

2) nexus-prisma for TS types

In some way, this problem could be solved by a generalized `nexus-prisma`, where the 

schema is no longer the Prisma Schema but some TypeScript types.

jasonkuhrt commented 4 years ago

@schickling if you could share a snippet of your use-case that would be helpful

schickling commented 4 years ago

Please treat this as "pseudo code" (i.e. not my "dream API")

schema.objectType({
  name: 'SpotifyTrack',
  rootTyping: 'SpotifyTrack',
  definition(t) {
    t.exposeRootFields('*')

    // could also be individual fields
    // t.exposeRootFields(['id', 'title'])
  },
})