f / f/graphql.js

Query merging does not work correctly.

Open
#61 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.3k
Forks
88
PR merge metrics
No merged PRs in 30d

Description

I have the following setup

```javascript
export const graph = graphql('/graphql', {
method: 'POST',
asJSON: true,
debug: true,
});

graph.fragment({
video: `on Video {
id
description
duration
videoType
}`,
category: `on Category {
id
name
categoryType
}`,
});

export const videos = graph.query('{ videos { ...video } }');

export const categories = graph.query('{ categories { ...category } }');
```

I try to use the "merge" functionality like so.
```javascript
queries.videos.merge('test');
queries.categories.merge('test');
queries.graph.commit('test').then((r) => console.log('all', r));
```

Now the query sent to my server is as follows.
```
query {
merge993382_videos :{ videos { ... video } }
merge278951_categories :{ categories { ... category } }
}

fragment video on Video {
id
description
duration
videoType
}

fragment category on Category {
id
name
categoryType
}
```

Which is, of course, invalid as the extra {} shouldn't be there around the query pieces.

I'm using graphql.js version 0.6.7

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.