Skip to content

Commit

Permalink
tidy up and make sure still works in build
Browse files Browse the repository at this point in the history
in particular, sort out webpack resolutions to work with .mjs
  • Loading branch information
wheresrhys committed Dec 7, 2020
1 parent c9b1e66 commit 5dde34e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 35 deletions.
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,3 @@ prepublish:
monorepo-publish: prepublish
npx athloi version --concurrency 10 $(CIRCLE_TAG)
npx athloi publish --concurrency 10 -- --access public

ct:
TREECREEPER_SCHEMA_DIRECTORY=example-schema node compose-test.js
7 changes: 0 additions & 7 deletions compose-test.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('graphql def creation', () => {
},
level: {
type: 'TrafficLight',
description: "How good it is"
description: 'How good it is',
},
hasBudget: {
type: 'CostCentre',
Expand Down Expand Up @@ -166,11 +166,11 @@ describe('graphql def creation', () => {
enums: {},
stringPatterns,
primitiveTypes: {
Word: {
graphql: 'String',
component: 'Text',
Word: {
graphql: 'String',
component: 'Text',
},
},
},
};
const generated = [].concat(...graphqlFromRawData(schema)).join('');
// note the regex has a space, not a new line
Expand Down Expand Up @@ -213,11 +213,11 @@ describe('graphql def creation', () => {
enums: {},
stringPatterns,
primitiveTypes: {
Word: {
graphql: 'String',
component: 'Text',
Word: {
graphql: 'String',
component: 'Text',
},
},
},
};
const generated = [].concat(...graphqlFromRawData(schema)).join('');
// note the regex has a space, not a new line
Expand Down Expand Up @@ -249,11 +249,11 @@ describe('graphql def creation', () => {
graphql: 'String',
component: 'Text',
},
Word: {
graphql: 'String',
component: 'Text',
Word: {
graphql: 'String',
component: 'Text',
},
},
},
};
const generated = [].concat(...graphqlFromRawData(schema)).join('');

Expand Down Expand Up @@ -281,11 +281,11 @@ line with
enums: {},
stringPatterns,
primitiveTypes: {
Word: {
graphql: 'String',
component: 'Text',
Word: {
graphql: 'String',
component: 'Text',
},
},
},
};
const generated = [].concat(...graphqlFromRawData(schema)).join('');
expect(generated).toMatch(
Expand Down
16 changes: 9 additions & 7 deletions packages/tc-schema-sdk/data-accessors/graphql-defs.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const getRelationshipTypeName = ({
);
};

const composeStaticDefinitions = composer => {
const addStaticDefinitions = composer => {
composer.addDirective(
new GraphQLDirective({
name: 'deprecated',
Expand All @@ -53,7 +53,7 @@ const composeStaticDefinitions = composer => {
composer.createScalarTC('Time');
};

const composeEnumDefinitions = (composer, sdk) => {
const addEnumDefinitions = (composer, sdk) => {
Object.entries(sdk.getEnums({ withMeta: true })).map(
([name, { description: enumDescription, options }]) => {
const values = {};
Expand Down Expand Up @@ -110,7 +110,6 @@ const composeObjectProperties = ({ typeName, properties, sdk, composer }) => {
extensions: {
directives: getDirectives(def),
},
// TODO - is pagination needed to be set explicitly
args: getArgs(def),
});

Expand Down Expand Up @@ -143,7 +142,6 @@ as well as on the records themselves. Use '${fieldName}' instead if you do not n
sdk.getRelationshipType(typeName, fieldName),
),
),
// TODO - is pagination needed to be set explicitly
args: getArgs(def),
});
}
Expand Down Expand Up @@ -173,7 +171,10 @@ const addTypeDefinition = (composer, sdk) => ({
...Object.fromEntries(
Object.entries(properties)
.filter(([, def]) => !def.relationship && !def.cypher)
.map(([name, { type }]) => [name, getGraphqlType(sdk)(type)]),
.map(([name, { type }]) => [
name,
getGraphqlType(sdk)(type),
]),
),
},
});
Expand Down Expand Up @@ -218,8 +219,8 @@ const addRelationshipTypeDefinition = (composer, sdk) => ({

const compose = sdk => {
const composer = new SchemaComposer();
composeStaticDefinitions(composer);
composeEnumDefinitions(composer, sdk);
addStaticDefinitions(composer);
addEnumDefinitions(composer, sdk);
sdk.getTypes({
includeMetaFields: true,
}).forEach(addTypeDefinition(composer, sdk));
Expand All @@ -234,6 +235,7 @@ const compose = sdk => {

module.exports = {
accessor() {
// still return an array for backwards compatibility... for now
return [compose(this).toSDL()];
},
};
7 changes: 6 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const filenameTemplate = '[name]';
module.exports = {
entry: ['./demo/cms/browser/main.js'],
resolve: {
extensions: ['.js', '.jsx', '.css'],
extensions: ['.mjs', '.js', '.jsx', '.css'],
},
output: {
path: path.resolve(__dirname, 'dist/browser'),
Expand All @@ -16,6 +16,11 @@ module.exports = {
stats: 'minimal',
module: {
rules: [
{
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
Expand Down

0 comments on commit 5dde34e

Please sign in to comment.