File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ export type GraphQLConfigEnpointsMapData = {
26
26
}
27
27
28
28
export type GraphQLConfigEnpointsMap = {
29
- [ env : string ] : GraphQLConfigEnpointConfig
29
+ [ env : string ] : GraphQLConfigEnpointConfig | GraphQLEndpoint
30
30
}
31
31
32
32
export type GraphQLConfigEnpointsData = GraphQLConfigEnpointsMapData
@@ -68,7 +68,15 @@ export class GraphQLEndpointsExtension {
68
68
) : GraphQLEndpoint {
69
69
const endpoint = this . getRawEndpoint ( endpointName )
70
70
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
72
80
} catch ( e ) {
73
81
e . message = `${ this . configPath } : ${ e . message } `
74
82
throw e
@@ -99,7 +107,7 @@ export class GraphQLEndpointsExtension {
99
107
)
100
108
}
101
109
102
- if ( ! endpoint . url ) {
110
+ if ( ! endpoint . url && ! ( endpoint instanceof GraphQLEndpoint ) ) {
103
111
throw new Error (
104
112
`${ this
105
113
. 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>(
15
15
config : T ,
16
16
env : { [ name : string ] : string | undefined } ,
17
17
) : T {
18
- config = Object . assign ( { } , config )
19
18
for ( let key in config ) {
20
19
const value = config [ key ]
21
20
if ( typeof value === 'string' ) {
You can’t perform that action at this time.
0 commit comments