-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(graphql-config): add graphql config extensions #1118
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e4c275e
feat(extensions): add graphql config extensions
1dd5c00
fix(extensions): use new node syntax
f4d926e
Merge branch 'master' into feat-extensions
5cdc15e
chore: merge with master
f6d8a56
fix: type of method in startServer
4d9138d
chore: add pull_request to ci trigger
1e43e06
refactor: remove duplicate extension apply code
2fe3e1d
test: add test for getGraphQLCache
f0f5af2
docs: add docs for startServer function
45c9323
chore: remove stale disabled deslint rule
9e3e973
docs: split readme of cli, server
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name: Node.JS CI | ||
on: [push] | ||
on: [push, pull_request] | ||
jobs: | ||
test: | ||
name: lint & test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
|
||
import * as net from 'net'; | ||
import { MessageProcessor } from './MessageProcessor'; | ||
import { GraphQLConfig } from 'graphql-config'; | ||
|
||
import { | ||
createMessageConnection, | ||
|
@@ -49,7 +50,10 @@ type Options = { | |
method?: 'socket' | 'stream' | 'node'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks incorrect. I think this should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed via f6d8a56 |
||
// the directory where graphql-config is found | ||
configDir?: string; | ||
// array of functions to transform the graphql-config and add extensions dynamically | ||
extensions?: Array<(config: GraphQLConfig) => GraphQLConfig>; | ||
}; | ||
('graphql-language-service-types'); | ||
|
||
/** | ||
* startServer - initialize LSP server with options | ||
|
@@ -86,7 +90,12 @@ export default async function startServer(options: Options): Promise<void> { | |
process.exit(0); | ||
}); | ||
const connection = createMessageConnection(reader, writer, logger); | ||
addHandlers(connection, logger, options.configDir); | ||
addHandlers( | ||
connection, | ||
logger, | ||
options.configDir, | ||
options.extensions, | ||
); | ||
connection.listen(); | ||
}) | ||
.listen(port); | ||
|
@@ -102,7 +111,7 @@ export default async function startServer(options: Options): Promise<void> { | |
break; | ||
} | ||
const connection = createMessageConnection(reader, writer, logger); | ||
addHandlers(connection, logger, options.configDir); | ||
addHandlers(connection, logger, options.configDir, options.extensions); | ||
connection.listen(); | ||
} | ||
} | ||
|
@@ -111,8 +120,9 @@ function addHandlers( | |
connection: MessageConnection, | ||
logger: Logger, | ||
configDir?: string, | ||
extensions?: Array<(config: GraphQLConfig) => GraphQLConfig>, | ||
): void { | ||
const messageProcessor = new MessageProcessor(logger); | ||
const messageProcessor = new MessageProcessor(logger, extensions); | ||
connection.onNotification( | ||
DidOpenTextDocumentNotification.type, | ||
async params => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@divyenduz so this is intended to re-declare
graphQLConfig
on every invocation? I'm guessing the result ofawait extension(graphQLConfig)
returns the previous config plus the extension?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.
Yes, as of now, the signature of an extension is a function that takes a GraphQLConfig as input and returns a GraphQL config as its output with the modification (extension) applied.
extensions?: Array<(config: GraphQLConfig) => GraphQLConfig>
Which implies,
extension: (config: GraphQLConfig) => GraphQLConfig