Skip to content
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
4 changes: 4 additions & 0 deletions codegen/schema/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Argument for generateSchema
, modulePath :: Nullable (Array String)
-- | Whether the schema should use newtypes. Necessary for circular/recursive schemas
, useNewtypesForRecords :: Nullable Boolean
-- | How to map graphQL types to Purescript types. The keys are graphql types and the values are purescript types you want them to be decoded as. Reasonable defaults are provided if you don't specify
, gqlScalarsToPursTypes :: Nullable (Object String)
-- | Extra imports for the generated enums
, enumImports :: Nullable (Array String)
-- | Custom code to add to the generated enums
Expand Down Expand Up @@ -66,6 +68,8 @@ Argument for generateSchema
, modulePath :: Nullable (Array String)
-- | Whether the schema should use newtypes. Necessary for circular/recursive schemas
, useNewtypesForRecords :: Nullable Boolean
-- | How to map graphQL types to Purescript types. The keys are graphql types and the values are purescript types you want them to be decoded as. Reasonable defaults are provided if you don't specify
, gqlScalarsToPursTypes :: Nullable (Object String)
-- | Extra imports for the generated enums
, enumImports :: Nullable (Array String)
-- | Custom code to add to the generated enums
Expand Down
11 changes: 11 additions & 0 deletions examples/8-custom-gql-types/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/bower_components/
/node_modules/
/.pulp-cache/
/output/
/generated-docs/
/.psc-package/
/.psc*
/.purs*
/.psa*
/.spago
/src/generated
4 changes: 4 additions & 0 deletions examples/8-custom-gql-types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
A codegen example using custom graphQL types. Look in `generate-purs-schema.js` to
see how types are mapped from graphQL to purescript.

Run `npm t` to see it in action
15 changes: 15 additions & 0 deletions examples/8-custom-gql-types/generate-purs-schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// In your code replace this line with the npm package:
// const { generateSchema } = require('purescript-graphql-client')
const { generateSchema } = require('../../codegen/schema')

module.exports = () =>
generateSchema({
dir: './src/generated',
modulePath: ['Generated', 'Gql', 'Admin'],
useNewtypesForRecords: false,
url: 'http://localhost:4000/graphql',
gqlScalarsToPursTypes: {
GqlTypeThatIsAString: 'String',
GqlTypeThatIsAnInt: 'Int'
}
})
Loading