Skip to content

Commit 31d7e0d

Browse files
authored
Update the example of handling assigned attributes (#1665)
* Update the example of handling assigned attributes * Add migration guide * Clean up example query after review
1 parent d48f331 commit 31d7e0d

30 files changed

+1629
-14
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
label: Interfaces
2+
position: 1
3+
link: null
4+
collapsible: true
5+
collapsed: true
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
api_reference: true
3+
id: assigned-attribute
4+
title: AssignedAttribute
5+
---
6+
7+
export const Bullet = () => <><span style={{ fontWeight: 'normal', fontSize: '.5em', color: 'var(--ifm-color-secondary-darkest)' }}>&nbsp;&nbsp;</span></>
8+
9+
export const SpecifiedBy = (props) => <>Specification<a className="link" style={{ fontSize:'1.5em', paddingLeft:'4px' }} target="\_blank" href={props.url} title={'Specified by ' + props.url}>⎘</a></>
10+
11+
export const Badge = (props) => <><span className={props.class}>{props.text}</span></>
12+
13+
import { useState } from 'react';
14+
15+
export const Details = ({ dataOpen, dataClose, children, startOpen = false }) => {
16+
const [open, setOpen] = useState(startOpen);
17+
return (
18+
<details {...(open ? { open: true } : {})} className="details" style={{ border:'none', boxShadow:'none', background:'var(--ifm-background-color)' }}>
19+
<summary
20+
onClick={(e) => {
21+
e.preventDefault();
22+
setOpen((open) => !open);
23+
}}
24+
style={{ listStyle:'none' }} >
25+
{open ? dataOpen : dataClose}
26+
</summary>
27+
{open && children}
28+
</details>
29+
);
30+
};
31+
32+
Represents an attribute assigned to an object.
33+
34+
35+
<Badge text="Added in Saleor 3.22 (unreleased)" class="badge badge--secondary margin-bottom--sm" />
36+
37+
38+
```graphql
39+
interface AssignedAttribute {
40+
attribute: Attribute!
41+
}
42+
```
43+
44+
### Fields
45+
46+
#### [<code style={{ fontWeight: 'normal' }}>AssignedAttribute.<b>attribute</b></code>](#)<Bullet />[`Attribute!`](../../../api-reference/attributes/objects/attribute.mdx) <Badge class="badge badge--secondary" text="non-null"/> <Badge class="badge badge--secondary" text="object"/> <Badge class="badge badge--secondary" text="attributes"/>
47+
48+
Attribute assigned to an object.
49+
50+
### Member Of
51+
52+
[`Page`](../../../api-reference/pages/objects/page.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`Product`](../../../api-reference/products/objects/product.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`ProductVariant`](../../../api-reference/products/objects/product-variant.mdx) <Badge class="badge badge--secondary" text="object"/>
53+
54+
### Implemented By
55+
56+
[`AssignedBooleanAttribute`](../../../api-reference/attributes/objects/assigned-boolean-attribute.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`AssignedDateAttribute`](../../../api-reference/attributes/objects/assigned-date-attribute.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`AssignedDateTimeAttribute`](../../../api-reference/attributes/objects/assigned-date-time-attribute.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`AssignedFileAttribute`](../../../api-reference/attributes/objects/assigned-file-attribute.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`AssignedMultiCategoryReferenceAttribute`](../../../api-reference/attributes/objects/assigned-multi-category-reference-attribute.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`AssignedMultiChoiceAttribute`](../../../api-reference/attributes/objects/assigned-multi-choice-attribute.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`AssignedMultiCollectionReferenceAttribute`](../../../api-reference/attributes/objects/assigned-multi-collection-reference-attribute.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`AssignedMultiPageReferenceAttribute`](../../../api-reference/attributes/objects/assigned-multi-page-reference-attribute.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`AssignedMultiProductReferenceAttribute`](../../../api-reference/attributes/objects/assigned-multi-product-reference-attribute.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`AssignedMultiProductVariantReferenceAttribute`](../../../api-reference/attributes/objects/assigned-multi-product-variant-reference-attribute.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`AssignedNumericAttribute`](../../../api-reference/attributes/objects/assigned-numeric-attribute.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`AssignedPlainTextAttribute`](../../../api-reference/attributes/objects/assigned-plain-text-attribute.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`AssignedSingleCategoryReferenceAttribute`](../../../api-reference/attributes/objects/assigned-single-category-reference-attribute.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`AssignedSingleChoiceAttribute`](../../../api-reference/attributes/objects/assigned-single-choice-attribute.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`AssignedSingleCollectionReferenceAttribute`](../../../api-reference/attributes/objects/assigned-single-collection-reference-attribute.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`AssignedSinglePageReferenceAttribute`](../../../api-reference/attributes/objects/assigned-single-page-reference-attribute.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`AssignedSingleProductReferenceAttribute`](../../../api-reference/attributes/objects/assigned-single-product-reference-attribute.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`AssignedSingleProductVariantReferenceAttribute`](../../../api-reference/attributes/objects/assigned-single-product-variant-reference-attribute.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`AssignedSwatchAttribute`](../../../api-reference/attributes/objects/assigned-swatch-attribute.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`AssignedTextAttribute`](../../../api-reference/attributes/objects/assigned-text-attribute.mdx) <Badge class="badge badge--secondary" text="object"/>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
api_reference: true
3+
id: assigned-boolean-attribute
4+
title: AssignedBooleanAttribute
5+
---
6+
7+
export const Bullet = () => <><span style={{ fontWeight: 'normal', fontSize: '.5em', color: 'var(--ifm-color-secondary-darkest)' }}>&nbsp;&nbsp;</span></>
8+
9+
export const SpecifiedBy = (props) => <>Specification<a className="link" style={{ fontSize:'1.5em', paddingLeft:'4px' }} target="\_blank" href={props.url} title={'Specified by ' + props.url}>⎘</a></>
10+
11+
export const Badge = (props) => <><span className={props.class}>{props.text}</span></>
12+
13+
import { useState } from 'react';
14+
15+
export const Details = ({ dataOpen, dataClose, children, startOpen = false }) => {
16+
const [open, setOpen] = useState(startOpen);
17+
return (
18+
<details {...(open ? { open: true } : {})} className="details" style={{ border:'none', boxShadow:'none', background:'var(--ifm-background-color)' }}>
19+
<summary
20+
onClick={(e) => {
21+
e.preventDefault();
22+
setOpen((open) => !open);
23+
}}
24+
style={{ listStyle:'none' }} >
25+
{open ? dataOpen : dataClose}
26+
</summary>
27+
{open && children}
28+
</details>
29+
);
30+
};
31+
32+
Represents a boolean attribute.
33+
34+
35+
<Badge text="Added in Saleor 3.22 (unreleased)" class="badge badge--secondary margin-bottom--sm" />
36+
37+
38+
```graphql
39+
type AssignedBooleanAttribute implements AssignedAttribute {
40+
attribute: Attribute!
41+
value: Boolean
42+
}
43+
```
44+
45+
### Fields
46+
47+
#### [<code style={{ fontWeight: 'normal' }}>AssignedBooleanAttribute.<b>attribute</b></code>](#)<Bullet />[`Attribute!`](../../../api-reference/attributes/objects/attribute.mdx) <Badge class="badge badge--secondary" text="non-null"/> <Badge class="badge badge--secondary" text="object"/> <Badge class="badge badge--secondary" text="attributes"/>
48+
49+
Attribute assigned to an object.
50+
51+
#### [<code style={{ fontWeight: 'normal' }}>AssignedBooleanAttribute.<b>value</b></code>](#)<Bullet />[`Boolean`](../../../api-reference/miscellaneous/scalars/boolean.mdx) <Badge class="badge badge--secondary" text="scalar"/> <Badge class="badge badge--secondary" text="miscellaneous"/>
52+
53+
The assigned boolean value.
54+
55+
### Interfaces
56+
57+
#### [`AssignedAttribute`](../../../api-reference/attributes/interfaces/assigned-attribute.mdx) <Badge class="badge badge--secondary" text="interface"/> <Badge class="badge badge--secondary" text="attributes"/>
58+
59+
Represents an attribute assigned to an object.
60+
61+
62+
<Badge text="Added in Saleor 3.22 (unreleased)" class="badge badge--secondary margin-bottom--sm" />
63+
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
api_reference: true
3+
id: assigned-choice-attribute-value
4+
title: AssignedChoiceAttributeValue
5+
---
6+
7+
export const Bullet = () => <><span style={{ fontWeight: 'normal', fontSize: '.5em', color: 'var(--ifm-color-secondary-darkest)' }}>&nbsp;&nbsp;</span></>
8+
9+
export const SpecifiedBy = (props) => <>Specification<a className="link" style={{ fontSize:'1.5em', paddingLeft:'4px' }} target="\_blank" href={props.url} title={'Specified by ' + props.url}>⎘</a></>
10+
11+
export const Badge = (props) => <><span className={props.class}>{props.text}</span></>
12+
13+
import { useState } from 'react';
14+
15+
export const Details = ({ dataOpen, dataClose, children, startOpen = false }) => {
16+
const [open, setOpen] = useState(startOpen);
17+
return (
18+
<details {...(open ? { open: true } : {})} className="details" style={{ border:'none', boxShadow:'none', background:'var(--ifm-background-color)' }}>
19+
<summary
20+
onClick={(e) => {
21+
e.preventDefault();
22+
setOpen((open) => !open);
23+
}}
24+
style={{ listStyle:'none' }} >
25+
{open ? dataOpen : dataClose}
26+
</summary>
27+
{open && children}
28+
</details>
29+
);
30+
};
31+
32+
Represents a single choice value of the attribute.
33+
34+
35+
<Badge text="Added in Saleor 3.22 (unreleased)" class="badge badge--secondary margin-bottom--sm" />
36+
37+
38+
```graphql
39+
type AssignedChoiceAttributeValue {
40+
name: String
41+
slug: String
42+
translation(languageCode: LanguageCodeEnum!): String
43+
}
44+
```
45+
46+
### Fields
47+
48+
#### [<code style={{ fontWeight: 'normal' }}>AssignedChoiceAttributeValue.<b>name</b></code>](#)<Bullet />[`String`](../../../api-reference/miscellaneous/scalars/string.mdx) <Badge class="badge badge--secondary" text="scalar"/> <Badge class="badge badge--secondary" text="miscellaneous"/>
49+
50+
Name of a value displayed in the interface.
51+
52+
#### [<code style={{ fontWeight: 'normal' }}>AssignedChoiceAttributeValue.<b>slug</b></code>](#)<Bullet />[`String`](../../../api-reference/miscellaneous/scalars/string.mdx) <Badge class="badge badge--secondary" text="scalar"/> <Badge class="badge badge--secondary" text="miscellaneous"/>
53+
54+
Internal representation of a value (unique per attribute).
55+
56+
#### [<code style={{ fontWeight: 'normal' }}>AssignedChoiceAttributeValue.<b>translation</b></code>](#)<Bullet />[`String`](../../../api-reference/miscellaneous/scalars/string.mdx) <Badge class="badge badge--secondary" text="scalar"/> <Badge class="badge badge--secondary" text="miscellaneous"/>
57+
58+
Translation of the name.
59+
60+
##### [<code style={{ fontWeight: 'normal' }}>AssignedChoiceAttributeValue.translation.<b>languageCode</b></code>](#)<Bullet />[`LanguageCodeEnum!`](../../../api-reference/miscellaneous/enums/language-code-enum.mdx) <Badge class="badge badge--secondary" text="non-null"/> <Badge class="badge badge--secondary" text="enum"/> <Badge class="badge badge--secondary" text="miscellaneous"/>
61+
62+
### Member Of
63+
64+
[`AssignedMultiChoiceAttribute`](../../../api-reference/attributes/objects/assigned-multi-choice-attribute.mdx) <Badge class="badge badge--secondary" text="object"/><Bullet />[`AssignedSingleChoiceAttribute`](../../../api-reference/attributes/objects/assigned-single-choice-attribute.mdx) <Badge class="badge badge--secondary" text="object"/>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
api_reference: true
3+
id: assigned-date-attribute
4+
title: AssignedDateAttribute
5+
---
6+
7+
export const Bullet = () => <><span style={{ fontWeight: 'normal', fontSize: '.5em', color: 'var(--ifm-color-secondary-darkest)' }}>&nbsp;&nbsp;</span></>
8+
9+
export const SpecifiedBy = (props) => <>Specification<a className="link" style={{ fontSize:'1.5em', paddingLeft:'4px' }} target="\_blank" href={props.url} title={'Specified by ' + props.url}>⎘</a></>
10+
11+
export const Badge = (props) => <><span className={props.class}>{props.text}</span></>
12+
13+
import { useState } from 'react';
14+
15+
export const Details = ({ dataOpen, dataClose, children, startOpen = false }) => {
16+
const [open, setOpen] = useState(startOpen);
17+
return (
18+
<details {...(open ? { open: true } : {})} className="details" style={{ border:'none', boxShadow:'none', background:'var(--ifm-background-color)' }}>
19+
<summary
20+
onClick={(e) => {
21+
e.preventDefault();
22+
setOpen((open) => !open);
23+
}}
24+
style={{ listStyle:'none' }} >
25+
{open ? dataOpen : dataClose}
26+
</summary>
27+
{open && children}
28+
</details>
29+
);
30+
};
31+
32+
Represents a date attribute.
33+
34+
35+
<Badge text="Added in Saleor 3.22 (unreleased)" class="badge badge--secondary margin-bottom--sm" />
36+
37+
38+
```graphql
39+
type AssignedDateAttribute implements AssignedAttribute {
40+
attribute: Attribute!
41+
value: Date
42+
}
43+
```
44+
45+
### Fields
46+
47+
#### [<code style={{ fontWeight: 'normal' }}>AssignedDateAttribute.<b>attribute</b></code>](#)<Bullet />[`Attribute!`](../../../api-reference/attributes/objects/attribute.mdx) <Badge class="badge badge--secondary" text="non-null"/> <Badge class="badge badge--secondary" text="object"/> <Badge class="badge badge--secondary" text="attributes"/>
48+
49+
Attribute assigned to an object.
50+
51+
#### [<code style={{ fontWeight: 'normal' }}>AssignedDateAttribute.<b>value</b></code>](#)<Bullet />[`Date`](../../../api-reference/miscellaneous/scalars/date.mdx) <Badge class="badge badge--secondary" text="scalar"/> <Badge class="badge badge--secondary" text="miscellaneous"/>
52+
53+
The assigned date value.
54+
55+
### Interfaces
56+
57+
#### [`AssignedAttribute`](../../../api-reference/attributes/interfaces/assigned-attribute.mdx) <Badge class="badge badge--secondary" text="interface"/> <Badge class="badge badge--secondary" text="attributes"/>
58+
59+
Represents an attribute assigned to an object.
60+
61+
62+
<Badge text="Added in Saleor 3.22 (unreleased)" class="badge badge--secondary margin-bottom--sm" />
63+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
api_reference: true
3+
id: assigned-date-time-attribute
4+
title: AssignedDateTimeAttribute
5+
---
6+
7+
export const Bullet = () => <><span style={{ fontWeight: 'normal', fontSize: '.5em', color: 'var(--ifm-color-secondary-darkest)' }}>&nbsp;&nbsp;</span></>
8+
9+
export const SpecifiedBy = (props) => <>Specification<a className="link" style={{ fontSize:'1.5em', paddingLeft:'4px' }} target="\_blank" href={props.url} title={'Specified by ' + props.url}>⎘</a></>
10+
11+
export const Badge = (props) => <><span className={props.class}>{props.text}</span></>
12+
13+
import { useState } from 'react';
14+
15+
export const Details = ({ dataOpen, dataClose, children, startOpen = false }) => {
16+
const [open, setOpen] = useState(startOpen);
17+
return (
18+
<details {...(open ? { open: true } : {})} className="details" style={{ border:'none', boxShadow:'none', background:'var(--ifm-background-color)' }}>
19+
<summary
20+
onClick={(e) => {
21+
e.preventDefault();
22+
setOpen((open) => !open);
23+
}}
24+
style={{ listStyle:'none' }} >
25+
{open ? dataOpen : dataClose}
26+
</summary>
27+
{open && children}
28+
</details>
29+
);
30+
};
31+
32+
Represents a date time attribute.
33+
34+
35+
<Badge text="Added in Saleor 3.22 (unreleased)" class="badge badge--secondary margin-bottom--sm" />
36+
37+
38+
```graphql
39+
type AssignedDateTimeAttribute implements AssignedAttribute {
40+
attribute: Attribute!
41+
value: DateTime
42+
}
43+
```
44+
45+
### Fields
46+
47+
#### [<code style={{ fontWeight: 'normal' }}>AssignedDateTimeAttribute.<b>attribute</b></code>](#)<Bullet />[`Attribute!`](../../../api-reference/attributes/objects/attribute.mdx) <Badge class="badge badge--secondary" text="non-null"/> <Badge class="badge badge--secondary" text="object"/> <Badge class="badge badge--secondary" text="attributes"/>
48+
49+
Attribute assigned to an object.
50+
51+
#### [<code style={{ fontWeight: 'normal' }}>AssignedDateTimeAttribute.<b>value</b></code>](#)<Bullet />[`DateTime`](../../../api-reference/miscellaneous/scalars/date-time.mdx) <Badge class="badge badge--secondary" text="scalar"/> <Badge class="badge badge--secondary" text="miscellaneous"/>
52+
53+
The assigned date time value.
54+
55+
### Interfaces
56+
57+
#### [`AssignedAttribute`](../../../api-reference/attributes/interfaces/assigned-attribute.mdx) <Badge class="badge badge--secondary" text="interface"/> <Badge class="badge badge--secondary" text="attributes"/>
58+
59+
Represents an attribute assigned to an object.
60+
61+
62+
<Badge text="Added in Saleor 3.22 (unreleased)" class="badge badge--secondary margin-bottom--sm" />
63+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
api_reference: true
3+
id: assigned-file-attribute
4+
title: AssignedFileAttribute
5+
---
6+
7+
export const Bullet = () => <><span style={{ fontWeight: 'normal', fontSize: '.5em', color: 'var(--ifm-color-secondary-darkest)' }}>&nbsp;&nbsp;</span></>
8+
9+
export const SpecifiedBy = (props) => <>Specification<a className="link" style={{ fontSize:'1.5em', paddingLeft:'4px' }} target="\_blank" href={props.url} title={'Specified by ' + props.url}>⎘</a></>
10+
11+
export const Badge = (props) => <><span className={props.class}>{props.text}</span></>
12+
13+
import { useState } from 'react';
14+
15+
export const Details = ({ dataOpen, dataClose, children, startOpen = false }) => {
16+
const [open, setOpen] = useState(startOpen);
17+
return (
18+
<details {...(open ? { open: true } : {})} className="details" style={{ border:'none', boxShadow:'none', background:'var(--ifm-background-color)' }}>
19+
<summary
20+
onClick={(e) => {
21+
e.preventDefault();
22+
setOpen((open) => !open);
23+
}}
24+
style={{ listStyle:'none' }} >
25+
{open ? dataOpen : dataClose}
26+
</summary>
27+
{open && children}
28+
</details>
29+
);
30+
};
31+
32+
Represents file attribute.
33+
34+
35+
<Badge text="Added in Saleor 3.22 (unreleased)" class="badge badge--secondary margin-bottom--sm" />
36+
37+
38+
```graphql
39+
type AssignedFileAttribute implements AssignedAttribute {
40+
attribute: Attribute!
41+
value: File
42+
}
43+
```
44+
45+
### Fields
46+
47+
#### [<code style={{ fontWeight: 'normal' }}>AssignedFileAttribute.<b>attribute</b></code>](#)<Bullet />[`Attribute!`](../../../api-reference/attributes/objects/attribute.mdx) <Badge class="badge badge--secondary" text="non-null"/> <Badge class="badge badge--secondary" text="object"/> <Badge class="badge badge--secondary" text="attributes"/>
48+
49+
Attribute assigned to an object.
50+
51+
#### [<code style={{ fontWeight: 'normal' }}>AssignedFileAttribute.<b>value</b></code>](#)<Bullet />[`File`](../../../api-reference/miscellaneous/objects/file.mdx) <Badge class="badge badge--secondary" text="object"/> <Badge class="badge badge--secondary" text="miscellaneous"/>
52+
53+
The assigned file.
54+
55+
### Interfaces
56+
57+
#### [`AssignedAttribute`](../../../api-reference/attributes/interfaces/assigned-attribute.mdx) <Badge class="badge badge--secondary" text="interface"/> <Badge class="badge badge--secondary" text="attributes"/>
58+
59+
Represents an attribute assigned to an object.
60+
61+
62+
<Badge text="Added in Saleor 3.22 (unreleased)" class="badge badge--secondary margin-bottom--sm" />
63+

0 commit comments

Comments
 (0)