File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ export type GraphQLConfigEnpointsMapData = {
2626}
2727
2828export type GraphQLConfigEnpointsMap = {
29- [ env : string ] : GraphQLConfigEnpointConfig
29+ [ env : string ] : GraphQLConfigEnpointConfig | GraphQLEndpoint
3030}
3131
3232export type GraphQLConfigEnpointsData = GraphQLConfigEnpointsMapData
@@ -68,7 +68,15 @@ export class GraphQLEndpointsExtension {
6868 ) : GraphQLEndpoint {
6969 const endpoint = this . getRawEndpoint ( endpointName )
7070 try {
71- return new GraphQLEndpoint ( resolveEnvsInValues ( endpoint , env ) )
71+ const resolved = resolveEnvsInValues ( endpoint , env )
72+
73+ // graphql-config extensions might have already instantiated a GraphQLEndpoint
74+ // or derived class from the GraphQLConfigEndpointConfig data. In that case,
75+ // getRawEndpoint will already return a GraphQLEndpoint and it should not be overwritten.
76+ if ( ! ( resolved instanceof GraphQLEndpoint ) ) {
77+ return new GraphQLEndpoint ( resolved )
78+ }
79+ return resolved
7280 } catch ( e ) {
7381 e . message = `${ this . configPath } : ${ e . message } `
7482 throw e
@@ -99,7 +107,7 @@ export class GraphQLEndpointsExtension {
99107 )
100108 }
101109
102- if ( ! endpoint . url ) {
110+ if ( ! endpoint . url && ! ( endpoint instanceof GraphQLEndpoint ) ) {
103111 throw new Error (
104112 `${ this
105113 . configPath } : "url" is required but is not specified for "${ endpointName } " endpoint`,
Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ export function resolveEnvsInValues<T extends any>(
1515 config : T ,
1616 env : { [ name : string ] : string | undefined } ,
1717) : T {
18- config = Object . assign ( { } , config )
1918 for ( let key in config ) {
2019 const value = config [ key ]
2120 if ( typeof value === 'string' ) {
You can’t perform that action at this time.
0 commit comments