Skip to content

Commit

Permalink
Merge pull request #341 from FormidableLabs/323-fix-serialization-of-…
Browse files Browse the repository at this point in the history
…default-obj-args

Add stringification of default input arguments
  • Loading branch information
andyrichardson authored Mar 18, 2021
2 parents 51d29fa + 65c7534 commit 87b6ac8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Binary file modified src/panel/__image_snapshots__/Schema - basic-landscape-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions src/panel/pages/request/components/Fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ export const Fields: FC<FieldProps> = ({ node, setType }) => {
<Deprecated>{`Deprecated: ${field.deprecationReason}`}</Deprecated>
) : null;

const getDefaultValue = (field: GraphQLInputField | GraphQLArgument) => {
return field.defaultValue !== undefined || null ? (
<Default>{` = ${field.defaultValue}`}</Default>
const getDefaultValue = (field: GraphQLInputField | GraphQLArgument) =>
field.defaultValue !== undefined || null ? (
<Default>{` = ${JSON.stringify(field.defaultValue)}`}</Default>
) : null;
};

const getDescription = (
field:
Expand Down
4 changes: 4 additions & 0 deletions src/panel/pages/request/components/Schema.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ type Query {
threads(sortBy: SortBy!, skip: Int = 0, limit: Int): [Thread!]!
thread(id: ID!): Thread
me: User
"""
Test with object for default args
"""
specificThread(thread: ThreadInput! = { title: "Test", text: "Hello" }): [Thread!]!
}
"Reply to a post, this is a little longer description"
Expand Down

0 comments on commit 87b6ac8

Please sign in to comment.