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

feat(api): Add session mutation #1176

Merged
merged 8 commits into from Mar 24, 2022
Merged

feat(api): Add session mutation #1176

merged 8 commits into from Mar 24, 2022

Conversation

igorbrasileiro
Copy link
Contributor

@igorbrasileiro igorbrasileiro commented Mar 17, 2022

What's the purpose of this pull request?

This PR adds the session query.

type StoreSession {
  channel: String
  country: String
  postalCode: String
}

input IStoreSession {
  channel: String
  country: String
    postalCode: String
}

type Mutation {
 """..."""
  session(session: IStoreSession!): StoreSession!
}

How it works?

The Session returns only the channel and the country. This is a partial Session, just to allow implement the VTEX regionalization that needs the regionId, that's is inside the channel.

How to test it?

base.store Deploy Preview

vtex-sites/base.store#392

References

@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 17, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 577881c:

Sandbox Source
Store UI Typescript Configuration

@igorbrasileiro igorbrasileiro self-assigned this Mar 17, 2022
Copy link
Member

@emersonlaurentino emersonlaurentino left a comment

Choose a reason for hiding this comment

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

Why getTypeDefs should return the Platform?

packages/api/src/platforms/vtex/resolvers/query.ts Outdated Show resolved Hide resolved
packages/api/src/platforms/vtex/resolvers/query.ts Outdated Show resolved Hide resolved
packages/api/src/typeDefs/index.ts Outdated Show resolved Hide resolved
@igorbrasileiro igorbrasileiro changed the title feat(api): Add custom typeDefs for VTEX platform and Region resolver feat(api): Add session query Mar 17, 2022
@igorbrasileiro igorbrasileiro changed the title feat(api): Add session query feat(api): Add session mutation Mar 22, 2022
Comment on lines +52 to +55
channel?: Maybe<Scalars['String']>;
country?: Maybe<Scalars['String']>;
postalCode?: Maybe<Scalars['String']>;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it updated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah


channelParser.updateChannel({ regionId: regionData?.[0]?.id })

return { ...session, channel: channelParser.stringify() }
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain why you chose to create this stringify function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the channel for all platforms is a string that should be handled only on the backend, for the front end is only a string.

Copy link
Contributor

@tlgimenes tlgimenes left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

@igorbrasileiro igorbrasileiro merged commit 0306167 into master Mar 24, 2022
@igorbrasileiro igorbrasileiro deleted the feat/region-query branch March 24, 2022 11:15
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.

None yet

5 participants