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

chore: Nullable Profile #1190

Merged
merged 2 commits into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion packages/api/src/__generated__/schema.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions packages/api/src/platforms/vtex/resolvers/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,16 @@ export const Query = {
} = ctx

const {
namespaces: { profile },
namespaces: { profile = null },
} = await commerce.session()

return {
id: profile?.id?.value ?? '',
email: profile?.email?.value ?? '',
givenName: profile?.firstName?.value ?? '',
familyName: profile?.lastName?.value ?? '',
}
return (
profile && {
id: profile.id?.value ?? '',
email: profile.email?.value ?? '',
givenName: profile.firstName?.value ?? '',
familyName: profile.lastName?.value ?? '',
}
)
},
}
2 changes: 2 additions & 0 deletions packages/api/src/typeDefs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Seo from './seo.graphql'
import Cart from './cart.graphql'
import Status from './status.graphql'
import PropertyValue from './propertyValue.graphql'
import Person from './person.graphql'

export const typeDefs = [
Query,
Expand All @@ -44,6 +45,7 @@ export const typeDefs = [
Cart,
Status,
PropertyValue,
Person,
]
.map(print)
.join('\n')
6 changes: 6 additions & 0 deletions packages/api/src/typeDefs/person.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type StorePerson {
id: String!
email: String!
givenName: String!
familyName: String!
}
9 changes: 1 addition & 8 deletions packages/api/src/typeDefs/query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ type StoreSearchResult {
facets: [StoreFacet!]!
}

type StorePerson {
id: String!
email: String!
givenName: String!
familyName: String!
}

type Query {
product(locator: [IStoreSelectedFacet!]!): StoreProduct!

Expand All @@ -68,5 +61,5 @@ type Query {

allCollections(first: Int!, after: String): StoreCollectionConnection!

person: StorePerson!
person: StorePerson
}