Closed ron-liu closed 7 years ago
I think that would be really really useful, and we want to implement that as well. Do you have any ideas for how this can be achieved? I'd say the best place to discuss is on graphql-tools where this functionality is implemented: https://github.com/apollostack/graphql-tools
@stubailo
Sorry I posted in wrong place, could you move this ticket this time?
I guess the root cause is graphl spec doesn't support it. I am going to walk around like below:
# author.js
export const gql = [`
type Author {
id: ID!
name: String!
}
`]
export const rootQuery = [`
authors: [Author]
`]
# book.js
export const gql = [`
type Book {
id: ID!
name: String!
}
`]
export const rootQuery = [`
books: [Book]
`]
// schema.js
import {gql:authorSchema, rootQuery: authroRootQuery} from './author'
import {gql: bookSchema, rootQuery: bookRootQuery} from './book'
export const schema = [...bookSchema, ...authSchema, `
type Query{
${[...authRootQuery, ...bookRootQuery].join('\n')}
}
`]
I know it is not a good idea :(, but that's all I can think of.
There's no way to move tickets, sorry!
@ron-liu do you know about the extend
syntax in GraphQL? It's not perfect, but maybe it will help you implement what you need? graphql-tools already supports it.
I know apollo-tools support merge multiple graphql files, but can I go further to split one type across multiple files, especially for the root
schema
like below?