-
Notifications
You must be signed in to change notification settings - Fork 70
Conversation
Checking this out. Thanks! |
@RomanGotsiy This looks amazing! I think I'll be able to merge this, but just in case am doing a super granular read for safety. One high level feedback - would it be possible to PR out the removal of |
Definitely! Would be great if you also can test it with Nuclide if possible as there may be some issues in
I think that no. Other packages depend on One more thing: there is probably a need to add some function for detecting and converting old config format to new just to support old configs. Do you think this is required? Do you want me to add this? |
I just realized that you've changed Since I'm late to suggest this change, if you've already made a lot of PRs to apply this to other repos, I'm fine with writing a function to enable backward-compatibility. |
this._graphQLConfig.getSchemaPath(appName), | ||
appName, | ||
); | ||
if (projectConfig.schemaPath) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this getter stuff ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requesting changes for getAutocompleteSuggestions
and the performance optimization, or we can discuss about the perf stuff.
@@ -103,10 +98,7 @@ export class GraphQLLanguageService { | |||
const appName = this._graphQLConfig.getAppConfigNameByFilePath(filePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed here I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be:
const projectConfig = this._graphQLConfig.getConfigForFile(filePath);
and so on, similar to getDiagnostics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Fixed.
Probably there is need to add some test-case that covers this piece of code
import {GraphQLLanguageService} from '../GraphQLLanguageService'; | ||
|
||
const MOCK_CONFIG = { | ||
inputDirs: ['./queries'], | ||
include: ['./queries/**'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love it
): Promise<Map<string, FragmentInfo>> => { | ||
// This function may be called from other classes. | ||
// If then, check the cache first. | ||
const rootDir = graphQLConfig.getRootDir(); | ||
const rootDir = projectConfig.configDir; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you forgot to do a getter for configDir
in https://github.com/graphcool/graphql-config/blob/master/src/GraphQLProjectConfig.ts, which makes me feel a little uncomfortable. If possible could we be consistent and use the proper getter? Not really a blocker though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, added getter for configDir.
excludeDirs.every( | ||
exclude => !fileInfo.filePath.startsWith(path.join(rootDir, exclude)), | ||
)); | ||
.filter(fileInfo => projectConfig.includesFile(fileInfo.filePath)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also a bug fix I think - thanks for that
|
||
const schemaFileExt = path.extname(schemaPath); | ||
let schema; | ||
let schemaSDL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm worried of the performance of this approach to generate GraphQL schema. From what I understand, this approach will read the file, build GraphQLSchema
object, print the schema in SDL format, and build it again. Last time I checked, buildSchema()
takes around several seconds with 4~5k types available, and with extendSchema()
being slow as well, this is definitely a hit with the performance.
I guess this is one of the ways to supprot .json
format, which previously had bugs with my implementation to append the custom directives in SDL format to content string. One easy performance optimization we can make is to optionally perform custom directive extension when customDirective
extension entry is available, with extendSchema
, not buildSchema
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea! I refactored code to use extendSchema
when customDirective
extension entry is available
Just one thing. It appeared that extendSchema
loses directive description. I've already opened a PR (#961) on graphql-js
to fix that but had to change ""
to undefined
in one test case for the time being (until my PR is merged)
Really amazing work @RomanGotsiy! |
Thanks, @asiandrummer! Let me know if there is anything else |
lgtm, cc @wincent for visibility
|
oops, missed that.
I partly agree. But at the same time globs are much more powerful. Let's say I want to exclude all the
while using On the other hand globs are harder to work with. + there is no simple and reliable way to convert glob to list of dirs. Does fb-watchman support globs? |
@RomanGotsiy sorry - I meant only the name, not the functionality :D I love the glob support! |
But if a user specifies glob |
Or maybe we could name them |
Yes! I love this idea 👍 I will update specification/implementation and this PR to use btw, You probably missed one |
Hey @asiandrummer, I've updated graphql-config and this PR to use |
Any update on this @asiandrummer? :) |
Sorry I've been away - thanks for the contribution! |
hey @asiandrummer ,
here is the PR to switch from
graphql-language-services-config
tographql-config
.I split it into 2 commits. First one removes
graphql-language-services-config
folder and the second one adds support for graphqlconfigAll the tests are passing and flow doesn't show any errors. Although it definitely requires looking from someone who knows the codebase