Skip to content

Commit

Permalink
Temporal solution
Browse files Browse the repository at this point in the history
-Hard code field name that can return null
-Added hardcoded CORS
  • Loading branch information
williamcabrera4 committed May 12, 2017
1 parent 09cd6ab commit ddb748b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,6 +2,7 @@
logs
*.log
npm-debug.log*
.idea

# Runtime data
pids
Expand Down
3 changes: 3 additions & 0 deletions src/fake_schema.ts
Expand Up @@ -126,6 +126,9 @@ export function fakeSchema(schema) {
}

function getResolver(type:GraphQLOutputType, field) {
if (field.name === 'currentOpenEnrollment' && getRandomInt(0, 10) < 5) {
return () => null
}

This comment has been minimized.

Copy link
@IvanGoncharov

IvanGoncharov May 12, 2017

Hi @williamcabrera4

I'm the author of graphql-faker and I just saw your fork.
And I'm trying to understand your use-case and how to better incorporate it in graphql-faker.
Do you need such functionality for every non-null field or only currentOpenEnrollment?

This comment has been minimized.

Copy link
@williamcabrera4

williamcabrera4 May 12, 2017

Author Owner

Hi @IvanGoncharov
I only want to be able to make a specific type or query to be able to return null
I hardcoded that type since it's the one i use on my test case but will be awesome to have some decorator on graphql-faker for that

This comment has been minimized.

Copy link
@IvanGoncharov

IvanGoncharov May 15, 2017

@williamcabrera4 Thanks for the details. A few more questions:
How do you think should an injection of null be configurable inside IDL?
Do you always need 50/50 chance or there are use-cases for different ratios?

This comment has been minimized.

Copy link
@williamcabrera4

williamcabrera4 May 17, 2017

Author Owner

It's just for testing, so the 50/50 was just to check the behavior for the two response

This comment has been minimized.

Copy link
@IvanGoncharov

IvanGoncharov May 17, 2017

@williamcabrera4 Thanks for answers. I need some time to figure out how to implement it properly.
I opened an issue so you can track progress and I don't forget about it.
graphql-kit#10

This comment has been minimized.

Copy link
@williamcabrera4

williamcabrera4 May 17, 2017

Author Owner

Awesome, thanks @IvanGoncharov !

if (type instanceof GraphQLNonNull)
return getResolver(type.ofType, field);
if (type instanceof GraphQLList)
Expand Down
6 changes: 2 additions & 4 deletions src/index.ts
Expand Up @@ -79,10 +79,8 @@ let fileName = fileArg || (argv.extend ?
const fakeDefinitionAST = readAST(path.join(__dirname, 'fake_definition.graphql'));
const corsOptions = {}

if (argv.co) {
corsOptions['origin'] = argv.co
corsOptions['credentials'] = true
}
corsOptions['origin'] = 'http://maxwellv5:8080'
corsOptions['credentials'] = true

let userIDL;
if (existsSync(fileName)) {
Expand Down

0 comments on commit ddb748b

Please sign in to comment.