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

refactor: to use combine adapters with one #1971

Merged
merged 9 commits into from
Jan 26, 2021
Merged

Conversation

tdeekens
Copy link
Contributor

Summary

This pull request experiments with the graphql-adapter and combine-adapters from @floplfip.

We don't have to use this functionality but I would like to propose it through this internally.

@vercel
Copy link

vercel bot commented Jan 11, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/commercetools/merchant-center-application-kit/ckfmqm8mn
✅ Preview: https://merchant-center-application-kit-git-feat-add-graphql-adapter.commercetools.vercel.app

@changeset-bot
Copy link

changeset-bot bot commented Jan 11, 2021

🦋 Changeset detected

Latest commit: 9b37abb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 29 packages
Name Type
@commercetools-backend/express Patch
@commercetools-backend/loggers Patch
@commercetools-frontend/actions-global Patch
@commercetools-frontend/application-components Patch
@commercetools-frontend/application-config Patch
@commercetools-frontend/application-shell-connectors Patch
@commercetools-frontend/application-shell Patch
@commercetools-frontend/assets Patch
@commercetools-frontend/babel-preset-mc-app Patch
@commercetools-frontend/browser-history Patch
@commercetools-frontend/constants Patch
@commercetools-frontend/create-mc-app Patch
@commercetools-frontend/cypress Patch
@commercetools-frontend/jest-preset-mc-app Patch
@commercetools-frontend/jest-stylelint-runner Patch
@commercetools-frontend/l10n Patch
@commercetools-frontend/mc-dev-authentication Patch
@commercetools-frontend/mc-html-template Patch
@commercetools-frontend/mc-scripts Patch
@commercetools-frontend/notifications Patch
@commercetools-frontend/permissions Patch
@commercetools-frontend/react-notifications Patch
@commercetools-frontend/sdk Patch
@commercetools-frontend/sentry Patch
merchant-center-application-template-starter Patch
playground Patch
@commercetools-local/visual-testing-app Patch
@commercetools-website/components-playground Patch
@commercetools-frontend/i18n Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel vercel bot temporarily deployed to Preview January 11, 2021 14:02 Inactive
Copy link
Member

@emmenko emmenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very promising. Thanks for pushing this 🤗

@vercel vercel bot temporarily deployed to Preview January 12, 2021 08:54 Inactive
@adnasa
Copy link
Contributor

adnasa commented Jan 12, 2021

I'm trying to review the implementation but I don't understand the application of graphql-adapter.
What do we get with this? 🤔

@tdeekens
Copy link
Contributor Author

I'm trying to review the implementation but I don't understand the application of graphql-adapter.
What do we get with this? 🤔

The idea is to homogenise the internal use of feature flags. We also have a fe-chapter issue about the topic.

The status quo internally is that we have:

  1. Long-lived feature configuration: e.g. if the dashboard is deployed to the given environment
  2. Short-lived feature flags: e.g. if platform limits are enabled

Both are rightfully configured in different systems. 1. is in our k8s files as a ConfigMap. 2. is in LaunchDarkly.

Now for either system or type of flag we use a different "backing system". For 1. we use @flopflip for 2. we use a useFeatureStatus (as we call it). This evaluates if it's possible to migrate both to only use @flopflip. It would load both types of flags and exposes them both to the FE. With that we could throw away all code we have around useFeatureStatus and remove confusion when to use what system or library.

@adnasa
Copy link
Contributor

adnasa commented Jan 12, 2021

aaah clear.
thanks for clarifying!

Copy link
Contributor

@adnasa adnasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. just a question

// This value is hard-coded here because we want to make sure that the
// app uses our account of LD. The value is meant to be public, so there
// is no need to be concerned about security.
const ldClientSideIdProduction = '5979d95f6040390cd07b5e01';

combineAdapters.combine([ldAdapter, graphqlAdapter]);

const getRequestHeaders = (props: Props) =>
Copy link
Contributor

@adnasa adnasa Jan 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apologies if I confuse things.

  • the getRequestHeaders is supposedly called with adapterArgs.
  • Here, we accept props..

Where did props come from?
maybe this is related to why you had to // @ts-expect-error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. That's a good catch!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping me when you resolve it ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I am doing this on the side. So might take some time :)

Copy link
Member

@emmenko emmenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I like it. It's also much simpler now!

@tdeekens
Copy link
Contributor Author

I think I am done on the @flopflip side. Type checks should also pass. Next would be experimenting with it internally.

@vercel vercel bot temporarily deployed to Preview January 14, 2021 23:55 Inactive
@tdeekens
Copy link
Contributor Author

So far so good

CleanShot 2021-01-15 at 00 54 26@2x

Need to fix 1-2 things in @flopflip I think how we can read these complex flag values now.

@vercel vercel bot temporarily deployed to Preview January 20, 2021 14:03 Inactive
@vercel vercel bot temporarily deployed to Preview January 20, 2021 14:37 Inactive
@vercel vercel bot temporarily deployed to Preview January 22, 2021 14:51 Inactive
@@ -81,15 +81,10 @@ const parseFlags = (fetchedFlags: TFetchedFlags): TParsedHttpAdapterFlags =>
])
);

type TAdditionalEnvironmentProperties = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I felt that anything that app-kit supports should be additional conceptually...

@@ -101,11 +96,11 @@ export const SetupFlopFlipProvider = (props: Props) => {
[allMenuFeatureToggles.allFeatureToggles, props.flags]
);
React.useMemo(() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple code is good code I think.

packages/constants/src/constants.ts Outdated Show resolved Hide resolved
@vercel vercel bot temporarily deployed to Preview January 22, 2021 15:00 Inactive
@vercel vercel bot temporarily deployed to Preview January 22, 2021 15:18 Inactive
@tdeekens tdeekens marked this pull request as ready for review January 22, 2021 15:19
@@ -143,7 +143,7 @@ export const SetupFlopFlipProvider = (props: Props) => {
});

return parseFlags(response.data);
}
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄

Copy link
Member

@emmenko emmenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good to me now. Don't forget to add the changeset.

@tdeekens
Copy link
Contributor Author

Yup. I want to beta test this a bit more. So I'll not merge it for now. I need time for that.

@vercel vercel bot temporarily deployed to Preview January 26, 2021 13:00 Inactive
@vercel vercel bot temporarily deployed to Preview January 26, 2021 13:15 Inactive
@tdeekens
Copy link
Contributor Author

tdeekens commented Jan 26, 2021

Ok. I did extensive testing internally. This works very nicely. Anything left here @emmenko otherwise I can start integrating.

I will share details of my integrating testing internally.

@tdeekens tdeekens requested a review from emmenko January 26, 2021 13:16
Copy link
Member

@emmenko emmenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Looking forward to see this in action 🚀

.changeset/dull-bees-obey.md Outdated Show resolved Hide resolved
Co-authored-by: Nicola Molinari <nicola.molinari@commercetools.de>
@vercel vercel bot temporarily deployed to Preview January 26, 2021 15:22 Inactive
@emmenko emmenko merged commit 3bf3299 into master Jan 26, 2021
@emmenko emmenko deleted the feat/add-graphql-adapter branch January 26, 2021 16:01
@ghost ghost mentioned this pull request Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants