Skip to content
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

Add graphql api creation by SDL url and introspection #845

Merged
merged 3 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export default function DefaultAPIForm(props) {
const {
onChange, onValidate, api, isAPIProduct, multiGateway,
isWebSocket, children, appendChildrenBeforeEndpoint, hideEndpoint,
readOnlyAPIEndpoint,
} = props;

const [validity, setValidity] = useState({});
Expand Down Expand Up @@ -594,6 +595,7 @@ export default function DefaultAPIForm(props) {
<TextField
fullWidth
id='itest-id-apiendpoint-input'
disabled={readOnlyAPIEndpoint !== null}
label={(
<FormattedMessage
id='Apis.Create.Components.DefaultAPIForm.api.endpoint'
Expand Down Expand Up @@ -756,6 +758,7 @@ DefaultAPIForm.defaultProps = {
onValidate: () => { },
api: {}, // Uncontrolled component
isWebSocket: false,
readOnlyAPIEndpoint: null,
};
DefaultAPIForm.propTypes = {
api: PropTypes.shape({}),
Expand All @@ -764,4 +767,5 @@ DefaultAPIForm.propTypes = {
isWebSocket: PropTypes.shape({}),
onChange: PropTypes.func.isRequired,
onValidate: PropTypes.func,
readOnlyAPIEndpoint: PropTypes.string,
};
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,14 @@ export default function ApiCreateGraphQL(props) {
case 'version':
case 'gatewayType':
case 'endpoint':
return { ...currentState, [action]: value };
nisan-abeywickrama marked this conversation as resolved.
Show resolved Hide resolved
case 'context':
case 'isFormValid':
return { ...currentState, [action]: value };
case 'inputType':
return { ...currentState, [action]: value, inputValue: value === 'url' ? '' : null };
return { ...currentState, [action]: value,
inputValue: value === 'url' || value === 'endpoint' ? '' : null
};
case 'graphQLInfo':
return { ...currentState, [action]: value };
case 'preSetAPI':
Expand Down Expand Up @@ -145,6 +148,7 @@ export default function ApiCreateGraphQL(props) {
endpoint,
gatewayType,
implementationType,
inputType,
inputValue,
graphQLInfo: { operations },
} = apiInputs;
Expand All @@ -166,7 +170,6 @@ export default function ApiCreateGraphQL(props) {
policies,
operations,
};
const uploadMethod = 'file';
if (endpoint) {
additionalProperties.endpointConfig = {
endpoint_type: 'http',
Expand All @@ -182,10 +185,14 @@ export default function ApiCreateGraphQL(props) {
const apiData = {
additionalProperties: JSON.stringify(additionalProperties),
implementationType,
[uploadMethod]: uploadMethod,
file: inputValue,
};

if (inputType === 'file') {
apiData.file = inputValue;
} else if (inputType === 'url' || inputType === 'endpoint') {
apiData.schema = apiInputs.graphQLInfo.graphQLSchema.schemaDefinition;
}
ashera96 marked this conversation as resolved.
Show resolved Hide resolved

newApi
.importGraphQL(apiData)
.then((response) => {
Expand Down Expand Up @@ -222,13 +229,14 @@ export default function ApiCreateGraphQL(props) {
<Typography variant='h5'>
<FormattedMessage
id='Apis.Create.GraphQL.ApiCreateGraphQL.heading'
defaultMessage='Create an API using a GraphQL SDL definition'
defaultMessage='Create a GraphQL API'
/>
</Typography>
<Typography variant='caption'>
<FormattedMessage
id='Apis.Create.GraphQL.ApiCreateGraphQL.sub.heading'
defaultMessage='Create an API by importing an existing GraphQL SDL definition.'
defaultMessage={'Create a GraphQL API by importing a SDL definition'
+ ' from a file or URL, or by using endpoint.'}
nisan-abeywickrama marked this conversation as resolved.
Show resolved Hide resolved
/>
</Typography>
</>
Expand Down Expand Up @@ -272,6 +280,7 @@ export default function ApiCreateGraphQL(props) {
multiGateway={multiGateway}
api={apiInputs}
isAPIProduct={false}
readOnlyAPIEndpoint={apiInputs.inputType==='endpoint' ? apiInputs.endpoint : null}
nisan-abeywickrama marked this conversation as resolved.
Show resolved Hide resolved
/>
)}
</Grid>
Expand Down
Loading
Loading