Closed dark06 closed 6 years ago
I am also looking to use fragments. I want to be able to import input types from other schema files. Is this possible with schemaglue?
Hi @dark06 and @bryanlvenable ,
I'm not sure I understand your question. To my knowledge, fragments are used to break down your GraphQL request (https://graphql.org/learn/queries/#fragments). ShchemaGlue allows to break down your GraphQL schema. I don't really understand how fragments fit into the GraphQL schema.
Would you mind to clarify your question?
Thanks a lot,
Nic
Apologies @nicolasdao, I am still learning GraphQL and it's terminologies. I think I meant was interfaces, not fragments. I want to be able to define an interface one one .graphql
file and import it to implement in other files.
For example
// characters/schema.graphql
interface Character {
id: ID!
name: String!
friends: [Character]
appearsIn: [Episode]!
}
// humans/schema.graphql
import { Character } from '../characters/schema');
// or
const Character = require('../characters/schema');
type Human implements Character {
id: ID!
name: String!
friends: [Character]
appearsIn: [Episode]!
starships: [Starship]
totalCredits: Int
}
@nicolasdao I went ahead and just tried it out, and it looks like I can get the functionality I wanted without require
or import
statements. Defining a type or interface in one .graphql
file can be used in another. Please consider my side of this issue ticket satisfied. Thanks for the awesome library, it is helping my code look clean and be easy to maintain and develop.
Hi @dark06 ,
I think the answer of @bryanlvenable above should also fix you up. Does that make sense?
Hello,
I want to define some fragments for specific schema. How is this possible? Can you give an example on how to implement that.
I am currently using the
mock_02
version of defining schema and resolverThanks