Open macrozone opened 6 years ago
Since Vulcan already takes strings and adds them to the schema I think it should work out of the box without that package. Have you tried it?
See http://docs.vulcanjs.org/graphql-schema.html#Custom-Schemas
(Use addGraphQLSchema()
btw, the docs are a little bit out of date)
@SachaG yes, i use that currently:
// ...
import MySchema from './MySchema.graphql';
addGraphQLSchema(MySchema.loc.source.body);
But this has some downsides (compared to the normal usage of swydo:graphql
):
# import
statements in the graphql file, because MySchema.loc.source.body
only contains the raw string (that's identical with just reading the file as string)would be cool beeing able to use
import MySchema from './MySchema.graphql';
addGraphQLSchema(MySchema);
MySchema
is an object of the shape
{
"kind": "Document",
"definitions": [
{
"kind": "ObjectTypeDefinition",
"name": {
"kind": "Name",
"value": "MyField"
},
// ...
]
},
// ...
so this definition list could maybe be merged with the parsed default schema that vulcan generates
The thing is, I don't know if makeExecutableSchema
can accept multiple typeDefs
? If not we'd need a way to merge different schema objects together but I don't really know how to do that…
Was at a @formidablelabs workshop recently and they mentioned @okgrow merge schema tool:
Oh interesting. @macrozone maybe you can give that a try? Here's where the magic happens:
(The weird formatting is to ensure the schema comes out right when you want to log it out)
Apollo also has a mergeSchema function
On Tue, Mar 13, 2018, 14:24 Sacha Greif notifications@github.com wrote:
Oh interesting. @macrozone https://github.com/macrozone maybe you can give that a try? Here's where the magic happens:
(The weird formatting is to ensure the schema comes out right when you want to log it out)
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/VulcanJS/Vulcan/issues/1926#issuecomment-372663428, or mute the thread https://github.com/notifications/unsubscribe-auth/AfguWx1qOo0OoyMSIr6_bzfQAF1x0OeVks5td8iEgaJpZM4Sod6c .
Maybe we can end up with 3 PRs for different solutions :) HAHAHA @MathiasKandelborg wins!
There's also https://github.com/creditkarma/graphql-loader which I think can merge schemas?
using https://github.com/Swydo/meteor-graphql you can load .graphql files in meteor applications.
this returns directly something that can be used in makeExecutableSchema.
unfortunatly, it does not play nice with vulcan, as there is no api to add these kind of typedefs.
Any way to use graphql files?