Falcon 2019 is now deprecated. If you have an existing Falcon 2019 project we are still commited to support you. Please get in touch for more information.
Version: current

GraphQL Schema Stitching

The whole GraphQL stitching is being performed by ExtensionContainer.createGraphQLConfig method.

ExtensionContainer collects all registered extensions and calls their getGraphQLConfig method which must return the following extConfig object:

class CustomExtension extends Extension {
async getGraphQLConfig() {
return {
schemas: [
`type CustomItem {
name: String
}`,
`extend Query {
findCustomItem(id: Int!): CustomItem
}`
],
resolvers: {
Query: {
findCustomItem: () => {
// add your logic here
return {
name: 'Item'
};
}
}
}
};
}
}
  • extConfig.schemas - is a string or array of strings which represent a valid GraphQL schema, for example:
extend Query {
getMyField: FieldType
}
type FieldType {
name: String
}

This way the main Query Type will be extended with a custom getMyField method which should return an instance of FieldType.

Please note, for all root types (Query, Mutation and Subscription) you must use extend statement in order to add your functionality into FalconServer GraphQL application. It is also possible to extend a GraphQL type, which is defined by other extensions - just use the same extend statement (for example, in your custom-extension you can extend Product type in shop-extension - extend Product { myCustomField: FieldType }).

  • extConfig.resolvers - resolvers object
  • extConfig.dataSources - simple object that represents Extension's

API DataSource instance (for example { wordpress: new WordpressApi() })

Ask the community. #help

If you can't find what you're looking for, the answer might be on our community slack channel. Our team keep a close eye on this and will usually get back to you within a few hours, if not straight away. If you haven't created an account yet please sign up here slack.deity.io.