You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ID: The ID scalar type represents a unique identifier, often used to refetch an object or as the key for a cache. The ID type is serialized in the same way as a String; however, defining it as an ID signifies that it is not intended to be human‐readable. https://graphql.org/learn/schema/#scalar-types
Closes: #187
Summary:
Adds support to specifying a field being of type GraphQLID. Add `format: id` or `format: uuid`.
Test Plan:
1. Change directory to `packages/openapi-to-graphql`
2. Run `npm run start_dev`
3. Browse to localhost:3000/graphql
4. Click on "Docs"
5. Click on "Query"
6. Observe the type of properties whose names end with "id"
Before:
company(id: String!): Company
office(accept: Accept, id: Int!): Office
productWithId(productId: String!, productTag: String!): ProductWithId
productsReviews(id: String!, limit: Int, productTag: String): [ProductsReviewsListItem]
After:
company(id: ID!): Company
office(accept: Accept, id: ID!): Office
productWithId(productId: ID!, productTag: String!): ProductWithId
productsReviews(id: ID!, limit: Int, productTag: String): [ProductsReviewsListItem]
7. Click on "Company"
8. Observe the type of "id"
Before:
id: String
The identifier of a company
After:
id: ID
The identifier of a company
9. Click "Back" twice
10. Click on "Mutation"
11. Click on "ProductWithIdInput"
12. Observe the type of "productId"
Before:
productId: String
The id of the product
After:
productId: ID
The id of the product
Signed-off-by: Omar Chehab <[email protected]>
Support emitting
GraphQLID
(https://graphql.org/graphql-js/type/#graphqlid)Implementation Details
I peeped around the codebase, here are some ideas I got:
File
schema_builder.ts
, functiongetScalarType
, addFile
oas_3_tools.ts
, functiongetSchemaType
, add something along the lines of:The text was updated successfully, but these errors were encountered: