Load config from apollo.config.js or package.json#497
Conversation
jbaxleyiii
left a comment
There was a problem hiding this comment.
@shadaj looks like a lot of formatting noise here?
I've left a couple comments on the loadingConfig function(s).
@martijnwalraven will have some feedback on the config format as well. Lets block on that
| if (flags.config) { | ||
| ctx.config = loadConfigFromFile(flags.config) || {}; | ||
| } else { | ||
| ctx.config = findAndLoadConfig(resolve(".")) || {}; |
There was a problem hiding this comment.
what is the goal of resolve(".") here?
| await promisify(fs.writeFile)(args.output, JSON.stringify(ctx.schema)); | ||
| }, | ||
| if (flags.config) { | ||
| ctx.config = loadConfigFromFile(flags.config) || {}; |
There was a problem hiding this comment.
it feels like we should be able to combine this and the next function for a shared loadConfig(path?) option that defaults to process.cwd()
| ? [obj.operations] | ||
| : obj.operations | ||
| ? (obj.operations as string[]) | ||
| : ["**/*.graphql"], |
There was a problem hiding this comment.
lets make sure to ignore node_modules by default
7610d4f to
55b5459
Compare
jbaxleyiii
left a comment
There was a problem hiding this comment.
@shadaj what does the load order look like if mutliple schema values are configured?
I.e. if I include a url + engineKey? Ideally we would want to check the url and if not found load from engine?
| } | ||
| task.title = `Scanning for GraphQL queries (${(ctx.documentSets as ResolvedDocumentSet[]) | ||
| .map(s => s.documentPaths.length) | ||
| .reduce((a, b) => a + b, 0)} found)`; // this is a bogus wrong value |
There was a problem hiding this comment.
is this bogus because its files not operations?
There was a problem hiding this comment.
Oops! It used to be really bogus (counted the number of document sets) before. I'll drop the comment.
|
|
||
| export interface ApolloConfig { | ||
| projectFolder: string; | ||
| projectName?: string; |
There was a problem hiding this comment.
can we change this to be just name?
What is the goal of projectFolder?
There was a problem hiding this comment.
projectFolder tracks where the root of the project is for handling relative glob paths. It can't be picked up from cwd always (in VSCode for example), so we treat it as a config value.
| schema?: string; | ||
| endpoint?: EndpointConfig; | ||
| engineKey?: string; | ||
| extends?: string; |
There was a problem hiding this comment.
how do we handle multiple extends? I'm assuming right now we don't
There was a problem hiding this comment.
So for me multiple extends didn't make too much sense because you're taking a schema and adjusting it. I'm not sure what it would mean to extend multiple schemas. In the future though, I would like to support multiple documents extending a schema in the case that you split up your types in multiple files.
|
The order for loading schemas is based on which data is closest:
|
Needs documentation, probably in a separate PR, but the implementation is ready.