-
Found the solution. Please delete this discussion. Sorry for the inconvenience. |
Beta Was this translation helpful? Give feedback.
Answered by
hayes
Jan 25, 2022
Replies: 1 comment 1 reply
-
Hey, sorry it took me a bit to get around to answering this. Generally the easiest way to do this is to create a structure like the following:
import SchemaBuilder from '@pothos/core';
export const builder = new SchemaBuilder({});
import { builder } from '../builder';
// exported so it can be imported/referenced by other types, but not required by Pothos
export const User = builder.objectRef<UserShape>('User')
User.implement({ fields: t => ({...}) });
import { builder } from './builder';
// import all your files that define types here
import './types/user';
import './types/posts';
export const schema = builder.toSchema({}); Now when you import your schema, that file imports each of the files that defines part of your schema, causing those definitions to be added to the builder before calling |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
hayes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, sorry it took me a bit to get around to answering this.
Generally the easiest way to do this is to create a structure like the following:
/builder.ts
/types/{typeName}.ts
(Or however you want to split up your files/schema.ts